Skip to content

Commit 8619983

Browse files
committed
initial
0 parents  commit 8619983

File tree

154 files changed

+12406
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

154 files changed

+12406
-0
lines changed

.gitignore

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# vs
2+
.vs/
3+
4+
# .net
5+
packages/
6+
ExtentReports/Program.cs
7+
ExtentReports/bin/
8+
ExtentReports/obj/
9+
ExtentReports/bin/debug/
10+
ExtentReports.Tests/bin/
11+
ExtentReports.Tests/obj/
12+
ExtentReports.Tests/Program.cs

ExtentReports.Tests/App.config

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
5+
</startup>
6+
</configuration>

ExtentReports.Tests/Base.cs

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System;
2+
using System.IO;
3+
4+
using AventStack.ExtentReports.Reporter;
5+
6+
using NUnit.Framework;
7+
8+
namespace AventStack.ExtentReports.Tests
9+
{
10+
[SetUpFixture]
11+
public abstract class Base
12+
{
13+
protected ExtentReports _extent;
14+
15+
[OneTimeSetUp]
16+
protected void Setup()
17+
{
18+
string dir = TestContext.CurrentContext.TestDirectory + "\\";
19+
var fileName = this.GetType().ToString() + ".html";
20+
ExtentHtmlReporter htmlReporter = new ExtentHtmlReporter(dir + fileName);
21+
22+
_extent = new ExtentReports();
23+
_extent.AttachReporter(htmlReporter);
24+
}
25+
26+
[OneTimeTearDown]
27+
protected void TearDown()
28+
{
29+
Console.WriteLine("in teardown");
30+
_extent.Flush();
31+
}
32+
}
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using NUnit.Framework;
2+
3+
using AventStack.ExtentReports.Gherkin.Model;
4+
5+
namespace AventStack.ExtentReports.Tests.APITests
6+
{
7+
[TestFixture]
8+
public class BddAttributesTests : Base
9+
{
10+
[Test]
11+
public void InitialTestIsOfBddType()
12+
{
13+
ExtentTest feature = _extent.CreateTest<Feature>(TestContext.CurrentContext.Test.Name);
14+
15+
Assert.True(feature.Model.IsBehaviorDrivenType);
16+
Assert.IsInstanceOf(typeof(Feature), feature.Model.BehaviorDrivenType);
17+
}
18+
19+
[Test]
20+
public void TestIsOfBddTypeWithBddChild()
21+
{
22+
ExtentTest feature = _extent.CreateTest<Feature>(TestContext.CurrentContext.Test.Name);
23+
ExtentTest scenario = feature.CreateNode<Scenario>("Scenario");
24+
25+
Assert.True(feature.Model.IsBehaviorDrivenType);
26+
Assert.True(scenario.Model.IsBehaviorDrivenType);
27+
Assert.IsInstanceOf(typeof(Feature), feature.Model.BehaviorDrivenType);
28+
Assert.IsInstanceOf(typeof(Scenario), scenario.Model.BehaviorDrivenType);
29+
}
30+
}
31+
}
+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using AventStack.ExtentReports.Gherkin.Model;
2+
using NUnit.Framework;
3+
4+
namespace AventStack.ExtentReports.Tests.APITests
5+
{
6+
[TestFixture]
7+
public class BddLevelsTests : Base
8+
{
9+
[Test]
10+
public void VerifyLevelsUsingGherkinKeyword()
11+
{
12+
var feature = _extent.CreateTest(TestContext.CurrentContext.Test.Name);
13+
var scenario = feature.CreateNode(new GherkinKeyword("Scenario"), "Child");
14+
var given = scenario.CreateNode(new GherkinKeyword("Given"), "Given").Info("Info");
15+
var and = scenario.CreateNode(new GherkinKeyword("And"), "And").Info("Info");
16+
var when = scenario.CreateNode(new GherkinKeyword("When"), "When").Info("Info");
17+
var then = scenario.CreateNode(new GherkinKeyword("Then"), "Then").Pass("Pass");
18+
19+
Assert.AreEqual(feature.Model.Level, 0);
20+
Assert.AreEqual(scenario.Model.Level, 1);
21+
Assert.AreEqual(given.Model.Level, 2);
22+
Assert.AreEqual(and.Model.Level, 2);
23+
Assert.AreEqual(when.Model.Level, 2);
24+
Assert.AreEqual(then.Model.Level, 2);
25+
}
26+
27+
[Test]
28+
public void VerifyLevelsUsingClass()
29+
{
30+
var feature = _extent.CreateTest(TestContext.CurrentContext.Test.Name);
31+
var scenario = feature.CreateNode<Scenario>("Child");
32+
var given = scenario.CreateNode<Given>("Given").Info("Info");
33+
var and = scenario.CreateNode<And>("And").Info("Info");
34+
var when = scenario.CreateNode<When>("When").Info("Info");
35+
var then = scenario.CreateNode<Then>("Then").Pass("Pass");
36+
37+
Assert.AreEqual(feature.Model.Level, 0);
38+
Assert.AreEqual(scenario.Model.Level, 1);
39+
Assert.AreEqual(given.Model.Level, 2);
40+
Assert.AreEqual(and.Model.Level, 2);
41+
Assert.AreEqual(when.Model.Level, 2);
42+
Assert.AreEqual(then.Model.Level, 2);
43+
}
44+
}
45+
}

0 commit comments

Comments
 (0)