-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* initial * bump dependency versions for tests, align views with latest java version * bump version (beta1) * #170 Fixes known dependency vulnerabilities * bump version (beta2) * Update Readme.md * closes #146 - remove test by test & node ID * minor code improvements * defaults searching for test by ID #146 * prepare release 5.0.0 --------- Co-authored-by: Anshoo Arora <[email protected]>
- Loading branch information
1 parent
482cc7e
commit a004f37
Showing
302 changed files
with
15,601 additions
and
10,684 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
using AventStack.ExtentReports.Config; | ||
using NUnit.Framework; | ||
|
||
namespace AventStack.ExtentReports.Tests.Config | ||
{ | ||
public class ConfigStoreTest | ||
{ | ||
private ConfigStore _store = new ConfigStore(); | ||
|
||
[Test] | ||
public void DuplicateConfig() | ||
{ | ||
_store.AddConfig("config", "value1"); | ||
Assert.AreEqual(_store.GetConfig("config"), "value1"); | ||
|
||
_store.AddConfig("config", "value2"); | ||
Assert.AreEqual(_store.GetConfig("config"), "value2"); | ||
} | ||
|
||
[Test] | ||
public void Contains() | ||
{ | ||
_store.AddConfig("config", "value1"); | ||
Assert.True(_store.Contains("config")); | ||
Assert.False(_store.Contains("config2")); | ||
} | ||
|
||
[Test] | ||
public void RemoveConfig() | ||
{ | ||
_store.AddConfig("config", "value1"); | ||
Assert.True(_store.Contains("config")); | ||
_store.RemoveConfig("config"); | ||
Assert.False(_store.Contains("config")); | ||
} | ||
|
||
[Test] | ||
public void ConfigValueTest() | ||
{ | ||
_store.AddConfig("c", "v"); | ||
_store.AddConfig("k", "z"); | ||
Assert.True(_store.GetConfig("c").Equals("v")); | ||
Assert.True(_store.GetConfig("k").Equals("z")); | ||
} | ||
|
||
[Test] | ||
public void ExtendConfigWithStore() | ||
{ | ||
var store1 = new ConfigStore(); | ||
store1.AddConfig("config1", "value1"); | ||
var store2 = new ConfigStore(); | ||
store2.AddConfig("config2", "value2"); | ||
store1.Extend(store2.Store); | ||
Assert.True(store1.Contains("config1")); | ||
Assert.True(store1.Contains("config2")); | ||
Assert.True(store2.Contains("config2")); | ||
Assert.False(store2.Contains("config1")); | ||
} | ||
|
||
[Test] | ||
public void ExtendConfigWithMap() | ||
{ | ||
var store1 = new ConfigStore(); | ||
store1.AddConfig("config1", "value1"); | ||
var store2 = new ConfigStore(); | ||
store2.AddConfig("config2", "value2"); | ||
store1.Extend(store2.Store); | ||
Assert.True(store1.Contains("config1")); | ||
Assert.True(store1.Contains("config2")); | ||
Assert.True(store2.Contains("config2")); | ||
Assert.False(store2.Contains("config1")); | ||
} | ||
|
||
[Test] | ||
public void ConfigEmpty() | ||
{ | ||
Assert.True(_store.IsEmpty); | ||
|
||
_store.AddConfig("config1", "value1"); | ||
Assert.False(_store.IsEmpty); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
using System.Linq; | ||
using AventStack.ExtentReports.Model; | ||
using AventStack.ExtentReports.Reporter; | ||
using NUnit.Framework; | ||
|
||
namespace AventStack.ExtentReports.Tests.Core | ||
{ | ||
public class AppenderTest | ||
{ | ||
private const string JsonArchive = "extent.json"; | ||
|
||
private ExtentReports _extent; | ||
|
||
[SetUp] | ||
public void Setup() | ||
{ | ||
_extent = new ExtentReports(); | ||
var json = new ExtentJsonFormatter(JsonArchive); | ||
_extent.AttachReporter(json); | ||
} | ||
|
||
[Test] | ||
public void TestWithLogs() | ||
{ | ||
// initial, create archive: | ||
var test1 = _extent.CreateTest("Testname1", "description1") | ||
.Pass("Pass") | ||
.Skip("Skip") | ||
.Fail("Fail"); | ||
var test2 = _extent.CreateTest("Testname2", "description2") | ||
.Warning("Warn") | ||
.Info("Info"); | ||
_extent.Flush(); | ||
|
||
// post, check archive | ||
var list = _extent.Report.Tests.ToList(); | ||
Assert.AreEqual(list.Count, 2); | ||
Assert.AreEqual(list[0].Status, test1.Status); | ||
Assert.AreEqual(list[1].Status, test2.Status); | ||
Assert.AreEqual(list[0].Name, test1.Test.Name); | ||
Assert.AreEqual(list[1].Name, test2.Test.Name); | ||
Assert.AreEqual(list[0].Description, test1.Test.Description); | ||
Assert.AreEqual(list[1].Description, test2.Test.Description); | ||
Assert.AreEqual(list[0].Logs.Count, test1.Test.Logs.Count); | ||
Assert.AreEqual(list[1].Logs.Count, test2.Test.Logs.Count); | ||
} | ||
|
||
[Test] | ||
public void TestWithChildren() | ||
{ | ||
// initial, create archive: | ||
var test1 = _extent.CreateTest("Testname1", "description1"); | ||
test1.CreateNode("Child1") | ||
.Pass("Pass") | ||
.Skip("Skip") | ||
.Fail("Fail"); | ||
var test2 = _extent.CreateTest("Testname2", "description2"); | ||
test2.CreateNode("Child2") | ||
.Warning("Warn") | ||
.Info("Info"); | ||
test2.CreateNode("Child3") | ||
.Pass("Pass"); | ||
_extent.Flush(); | ||
|
||
// post, check archive | ||
_extent = new ExtentReports(); | ||
Assert.AreEqual(0, _extent.Report.Tests.Count); | ||
_extent.CreateDomainFromJsonArchive(JsonArchive); | ||
var list = _extent.Report.Tests.ToList(); | ||
|
||
// parent checks | ||
Assert.AreEqual(list.Count, 2); | ||
Assert.AreEqual(list[0].Children.Count, 1); | ||
Assert.AreEqual(list[1].Children.Count, 2); | ||
Assert.AreEqual(list[0].Status, test1.Status); | ||
Assert.AreEqual(list[1].Status, test2.Status); | ||
Assert.AreEqual(list[0].Name, test1.Test.Name); | ||
Assert.AreEqual(list[1].Name, test2.Test.Name); | ||
Assert.AreEqual(list[0].Description, test1.Test.Description); | ||
Assert.AreEqual(list[1].Description, test2.Test.Description); | ||
Assert.AreEqual(list[0].Logs.Count, test1.Test.Logs.Count); | ||
Assert.AreEqual(list[1].Logs.Count, test2.Test.Logs.Count); | ||
} | ||
|
||
[Test] | ||
public void Children() | ||
{ | ||
// initial, create archive: | ||
ExtentTest test1 = _extent.CreateTest("Testname1", "description1"); | ||
ExtentTest child1 = test1.CreateNode("Child1") | ||
.Pass("Pass") | ||
.Skip("Skip") | ||
.Fail("Fail"); | ||
ExtentTest test2 = _extent.CreateTest("Testname2", "description2"); | ||
ExtentTest child2 = test2.CreateNode("Child2") | ||
.Warning("Warn") | ||
.Info("Info"); | ||
ExtentTest child3 = test2.CreateNode("Child3") | ||
.Pass("Pass"); | ||
_extent.Flush(); | ||
|
||
// post, check archive | ||
_extent = new ExtentReports(); | ||
_extent.CreateDomainFromJsonArchive(JsonArchive); | ||
var list = _extent.Report.Tests.ToList(); | ||
|
||
Assert.IsNotEmpty(list); | ||
Assert.IsNotEmpty(list[0].Children); | ||
|
||
// children checks | ||
Assert.AreEqual(list[0].Children.First().Name, child1.Test.Name); | ||
Assert.AreEqual(list[1].Children.First().Name, child2.Test.Name); | ||
Assert.AreEqual(list[0].Children.First().Logs.Count, child1.Test.Logs.Count); | ||
Assert.AreEqual(list[1].Children.First().Logs.Count, child2.Test.Logs.Count); | ||
list[1].Children.RemoveAt(0); | ||
Assert.AreEqual(list[1].Children.First().Name, child3.Test.Name); | ||
Assert.AreEqual(list[1].Children.First().Logs.Count, child3.Test.Logs.Count); | ||
} | ||
|
||
[Test] | ||
public void TestWithMedia() | ||
{ | ||
// initial, create archive: | ||
var test1 = _extent.CreateTest("Testname1") | ||
.AddScreenCaptureFromPath("img.png") | ||
.Fail("Fail", MediaEntityBuilder.CreateScreenCaptureFromPath("img.png").Build()); | ||
_extent.Flush(); | ||
|
||
// post, check archive | ||
_extent = new ExtentReports(); | ||
_extent.CreateDomainFromJsonArchive(JsonArchive); | ||
var list = _extent.Report.Tests.ToList(); | ||
|
||
// parent checks | ||
Assert.AreEqual(list.Count, 1); | ||
Assert.AreEqual(list[0].Media.Count, 1); | ||
Assert.NotNull(list[0].Logs.First().Media); | ||
Assert.AreEqual(list[0].Media[0].Path, test1.Test.Media[0].Path); | ||
Assert.AreEqual(list[0].Logs.First().Media.Path, | ||
test1.Test.Logs.First().Media.Path); | ||
} | ||
|
||
[Test] | ||
public void TestWithMediaBase64() | ||
{ | ||
// initial, create archive: | ||
var test1 = _extent.CreateTest("Testname1") | ||
.AddScreenCaptureFromBase64String("base64string") | ||
.Fail("Fail", MediaEntityBuilder.CreateScreenCaptureFromBase64String("base64string").Build()); | ||
_extent.Flush(); | ||
|
||
// post, check archive | ||
_extent = new ExtentReports(); | ||
_extent.CreateDomainFromJsonArchive(JsonArchive); | ||
var list = _extent.Report.Tests.ToList(); | ||
|
||
// parent checks | ||
Assert.AreEqual(list.Count, 1); | ||
Assert.AreEqual(list[0].Media.Count, 1); | ||
Assert.NotNull(list[0].Logs.First().Media); | ||
Assert.AreEqual(((ScreenCapture)list[0].Media[0]).Base64, | ||
((ScreenCapture)test1.Test.Media[0]).Base64); | ||
Assert.AreEqual(((ScreenCapture)list[0].Logs.First().Media).Base64, | ||
((ScreenCapture)test1.Test.Logs.First().Media).Base64); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
using AventStack.ExtentReports.Gherkin.Model; | ||
using AventStack.ExtentReports.Model; | ||
using NUnit.Framework; | ||
|
||
namespace AventStack.ExtentReports.Tests.Core | ||
{ | ||
public class BddTypeTest | ||
{ | ||
private ExtentReports _extent; | ||
|
||
[SetUp] | ||
public void Setup() | ||
{ | ||
_extent = new ExtentReports(); | ||
} | ||
|
||
[Test] | ||
public void FeatureIsOfBddType() | ||
{ | ||
var feature = _extent.CreateTest<Feature>(TestContext.CurrentContext.Test.Name); | ||
Assert.True(feature.Test.IsBdd); | ||
Assert.AreEqual(feature.Test.BddType.Name, "Feature"); | ||
} | ||
|
||
[Test] | ||
public void ScenarioIsOfBddTypeWithBddChild() | ||
{ | ||
var feature = _extent.CreateTest<Feature>(TestContext.CurrentContext.Test.Name); | ||
var scenario = feature.CreateNode<Scenario>("Scenario"); | ||
Assert.True(scenario.Test.IsBdd); | ||
Assert.AreEqual(scenario.Test.BddType.Name, "Scenario"); | ||
} | ||
|
||
[Test] | ||
public void ScenarioOutlineIsOfBddTypeWithBddChild() | ||
{ | ||
var feature = _extent.CreateTest<Feature>(TestContext.CurrentContext.Test.Name); | ||
var scenarioOutline = feature.CreateNode<ScenarioOutline>("ScenarioOutline"); | ||
Assert.True(scenarioOutline.Test.IsBdd); | ||
Assert.AreEqual(scenarioOutline.Test.BddType.Name, "ScenarioOutline"); | ||
} | ||
|
||
[Test] | ||
public void AndIsOfBddTypeWithBddChild() | ||
{ | ||
var feature = _extent.CreateTest<Feature>(TestContext.CurrentContext.Test.Name); | ||
var scenario = feature.CreateNode<Scenario>("Scenario"); | ||
var and = scenario.CreateNode<And>("And"); | ||
Assert.True(and.Test.IsBdd); | ||
Assert.AreEqual(and.Test.BddType.Name, "And"); | ||
} | ||
|
||
[Test] | ||
public void AsteriskIsOfBddTypeWithBddChild() | ||
{ | ||
var feature = _extent.CreateTest<Feature>(TestContext.CurrentContext.Test.Name); | ||
var scenario = feature.CreateNode<Scenario>("Scenario"); | ||
var asterisk = scenario.CreateNode<Asterisk>("Asterisk"); | ||
Assert.True(asterisk.Test.IsBdd); | ||
Assert.AreEqual(asterisk.Test.BddType.Name, "*"); | ||
} | ||
|
||
[Test] | ||
public void BackgroundIsOfBddTypeWithBddChild() | ||
{ | ||
var feature = _extent.CreateTest<Feature>(TestContext.CurrentContext.Test.Name); | ||
var scenario = feature.CreateNode<Scenario>("Scenario"); | ||
var background = scenario.CreateNode<Background>("Background"); | ||
Assert.True(background.Test.IsBdd); | ||
Assert.AreEqual(background.Test.BddType.Name, "Background"); | ||
} | ||
|
||
[Test] | ||
public void ButIsOfBddTypeWithBddChild() | ||
{ | ||
var feature = _extent.CreateTest<Feature>(TestContext.CurrentContext.Test.Name); | ||
var scenario = feature.CreateNode<Scenario>("Scenario"); | ||
var but = scenario.CreateNode<But>("But"); | ||
Assert.True(but.Test.IsBdd); | ||
Assert.AreEqual(but.Test.BddType.Name, "But"); | ||
} | ||
|
||
[Test] | ||
public void GivenIsOfBddTypeWithBddChild() | ||
{ | ||
var feature = _extent.CreateTest<Feature>(TestContext.CurrentContext.Test.Name); | ||
var scenario = feature.CreateNode<Scenario>("Scenario"); | ||
var given = scenario.CreateNode<Given>("Given"); | ||
Assert.True(given.Test.IsBdd); | ||
Assert.AreEqual(given.Test.BddType.Name, "Given"); | ||
} | ||
|
||
[Test] | ||
public void ThenIsOfBddTypeWithBddChild() | ||
{ | ||
var feature = _extent.CreateTest<Feature>(TestContext.CurrentContext.Test.Name); | ||
var scenario = feature.CreateNode<Scenario>("Scenario"); | ||
var then = scenario.CreateNode<Then>("Then"); | ||
Assert.True(then.Test.IsBdd); | ||
Assert.AreEqual(then.Test.BddType.Name, "Then"); | ||
} | ||
|
||
[Test] | ||
public void WhenIsOfBddTypeWithBddChild() | ||
{ | ||
var feature = _extent.CreateTest<Feature>(TestContext.CurrentContext.Test.Name); | ||
var scenario = feature.CreateNode<Scenario>("Scenario"); | ||
var when = scenario.CreateNode<When>("When"); | ||
Assert.True(when.Test.IsBdd); | ||
Assert.AreEqual(when.Test.BddType.Name, "When"); | ||
} | ||
} | ||
} |
Oops, something went wrong.