Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions EnvironmentFixture/SetupFixture.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using NUnit.Framework;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;

namespace NUnitDemo.EnvironmentFixture
{
[SetUpFixture]
[Parallelizable]
public class BaseClass
{
public IWebDriver driver;

[OneTimeSetUp]
public void setupMethod()
{
driver = new ChromeDriver();
}

[OneTimeTearDown]
public void terminateMethod()
{
driver.Quit();

Assert.Pass("Test success");
}
}
}
32 changes: 32 additions & 0 deletions EnvironmentFixture/Test01.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using NUnit.Framework;
using NUnitDemo.EnvironmentFixture;
using System.Threading;

namespace NUnitDemo.ParallelTestExecution
{
[TestFixture]
public class Test01 : BaseClass
{
[SetUp]
public void testsetup()
{
driver.Url = "http://google.com";
}

[Test]
public void TestMethod()
{
var answer = 42;
Assert.That(answer, Is.EqualTo(42), "Some useful error message");
driver.Url = "http://map.google.com";
Thread.Sleep(3000);
}

[Test]
public void Testsecondmethod()
{
driver.Url = "http://web.skype.com";
Thread.Sleep(3000);
}
}
}
21 changes: 21 additions & 0 deletions EnvironmentFixture/Test02.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using NUnit.Framework;
using NUnitDemo.EnvironmentFixture;
using System.Threading;

namespace NUnitDemo.ParallelTestExecution
{
[TestFixture]
public class Test02 : BaseClass
{
[Test]
public void TestMethod()
{
driver.Url = "http://gmail.com";
Thread.Sleep(3000);

// TODO: Add your test code here
var answer = 43;
Assert.That(answer, Is.GreaterThan(42), "Some useful error message");
}
}
}
40 changes: 38 additions & 2 deletions ExtentReportV3/v3A_SimpleExtentLogs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
using AventStack.ExtentReports.Reporter;
using AventStack.ExtentReports.Reporter.Configuration;
using NUnit.Framework;
using System;
using System.IO;

namespace NUnitDemo.ExtentReportV4
{
Expand All @@ -13,7 +15,7 @@ public class V3A_SimpleExtentLogs
public void TestMethod()
{
//To create report object
var htmlReporter = new ExtentV3HtmlReporter("E:\\"+ this.GetType().Name + ".html");
var htmlReporter = new ExtentV3HtmlReporter("E:\\" + this.GetType().Name + ".html");
var extent = new ExtentReports();
extent.AttachReporter(htmlReporter);
ExtentTest extentTest;
Expand All @@ -30,7 +32,7 @@ public void TestMethod()
htmlReporter.Config.DocumentTitle = "This is Document Title";

//Create simple logs
extentTest = extent.CreateTest("Simple Logs");
extentTest = extent.CreateTest("Simple Logs", "<i>This is simple log description.</i>");
extentTest.Info("This is Info Log");
extentTest.Pass("This is Pass Log");
extentTest.Fail("This is Fail Log");
Expand All @@ -57,6 +59,40 @@ public void TestMethod()
extentTest.Warning(MarkupHelper.CreateLabel("This is Warning Log", ExtentColor.Lime));

extent.Flush();

double per = extent.Stats.ParentPercentageFail + extent.Stats.ChildPercentageFail;
string testStatus = "";

if (per > 0)
testStatus = "Fail";
else
testStatus = "Pass";

string date = DateTime.Now.ToString("dd-MM-yyyy");
String result = this.GetType().Name + "\t" + testStatus + "\t" + htmlReporter.StartTime.TimeOfDay + "\t" + htmlReporter.EndTime.TimeOfDay;

if (!File.Exists("E:/" + date + ".html"))
{
result = "<table border='1'>"
+ "<col width = '600'>" + "<col width = '60'>" + "<col width = '200'>" + "<col width = '200'>"
+ "<tr> <td colspan=4> <h1 align = 'center'> Automation Script Test Report for the Day</h1></td></tr>"
+ "<tr>"
+ "<th align='left'>TestName</th>"
+ "<th align='left'>Status</th>"
+ "<th align='left'>StartTime</th>"
+ "<th align='left'>EndTime</th>"
+ "</tr>";
File.AppendAllText("E:/" + date + ".html", result + Environment.NewLine);
}

result = "<tr>"
+ "<td>" + this.GetType().Name + "</td>"
+ "<td>" + testStatus + "</td >"
+ "<td>" + htmlReporter.StartTime.TimeOfDay + "</td>"
+ "<td>" + htmlReporter.EndTime.TimeOfDay + "</td>"
+ "</tr>";

File.AppendAllText("E:/" + date + ".html", result + Environment.NewLine);
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion ExtentReportV3/v3B_ExtentLogWithTitleDescription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
using AventStack.ExtentReports.MarkupUtils;
using AventStack.ExtentReports.Reporter;
using NUnit.Framework;
using System;
using System.IO;

namespace NUnitDemo.ExtentReportV4
{
[TestFixture]
public class V3B_ExtentLogWithTitleDescription
public class V3B_ExtentLogWithTitleDescriptionV3B_ExtentLogWithTitleDescription
{
[Test]
public void TestMethod()
Expand Down
36 changes: 36 additions & 0 deletions ExtentReportV3/v3F_LogTestStatus.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NUnitDemo.ExtentReportV3
{
class v3F_LogTestStatus
{
//public void endUp()
//{
//double per = extent.Stats.ParentPercentageFail + extent.Stats.ChildPercentageFail;
//string testStatus = "";

// if (per > 0)
// testStatus = "Fail";
// else
// testStatus = "Pass";

// string date = DateTime.Now.ToString("dd-MM-yyyy");


//String result = this.GetType().Name + "\t" + testStatus + "\t" + htmlReporter.StartTime.TimeOfDay + "\t" + htmlReporter.EndTime.TimeOfDay;

//result = "<html> <body><table> <tr> " +
// "<td width = '600px'>" + this.GetType().Name + "</td >" +
// "<td width = '50px'>" + testStatus + "</td >" +
// "<td width = '200px'>" + htmlReporter.StartTime.TimeOfDay + "</td>" +
// "<td width = '200px'>" + htmlReporter.EndTime.TimeOfDay + "</td>" +
// "</tr > </table > </body> </html>";

// File.AppendAllText("E:/" + date + ".html", result + Environment.NewLine);
//}
}
}
2 changes: 1 addition & 1 deletion ExtentReportV4/A_SimpleExtentLogs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void TestMethod()
extentTest.Fail(MarkupHelper.CreateLabel("This is Fail Log", ExtentColor.Purple));
extentTest.Fatal(MarkupHelper.CreateLabel("This is Fatal Log", ExtentColor.Transparent));
extentTest.Warning(MarkupHelper.CreateLabel("This is Warning Log", ExtentColor.Lime));

extent.Flush();
}
}
Expand Down
18 changes: 7 additions & 11 deletions ExtentReportV4/C_ExtentLogsWithChildNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,23 @@
using AventStack.ExtentReports.MarkupUtils;
using AventStack.ExtentReports.Reporter;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NUnitDemo.ExtentReportV4
{
[TestFixture]
public class C_ExtentLogsWithChildNode
{
//To create report object
ExtentHtmlReporter htmlReporter = new ExtentHtmlReporter("E:\\Test.html");
ExtentReports extent = new ExtentReports();

ExtentTest testlog;
ExtentTest childLog;

[Test]
public void TestMethod()
{
//To create report object
var htmlReporter = new ExtentHtmlReporter("E:\\Test.html");
var extent = new ExtentReports();
extent.AttachReporter(htmlReporter);
ExtentTest testlog;
ExtentTest childLog;

testlog = extent.CreateTest("Test log with Child node");
testlog.Log(Status.Info, MarkupHelper.CreateLabel("This is Info log", ExtentColor.Orange));
Expand All @@ -32,7 +29,6 @@ public void TestMethod()
childLog.Info("This is Info log");
childLog.Pass("This is Pass log");
childLog.Fail("This is Fail log");

extent.Flush();
}
}
Expand Down
3 changes: 2 additions & 1 deletion ExtentReportV4/D_ExtentLogWithChildNodeTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using AventStack.ExtentReports.MarkupUtils;
using AventStack.ExtentReports.Reporter;
using NUnit.Framework;
using System;

namespace NUnitDemo.ExtentReportV4
{
Expand Down Expand Up @@ -35,7 +36,7 @@ public void TestMethod()
childLog = testlog.CreateNode("Childnode-3");
childLog.Info("This is Info log");
childLog.Pass("This is Pass log");
childLog.Warning("This is Warning log");
childLog.Warning("This is Warning log");

extent.Flush();
}
Expand Down
2 changes: 1 addition & 1 deletion Logs/TEST.log
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2019-01-28 14:44:13,264 INFO [Worker#STA_NP] NUnitDemo.SeleniumCommonTech.F_ReadExcel.ReadValue - Test-1

1 change: 1 addition & 0 deletions Logs/TEST.log.2019-01-28
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2019-01-28 14:44:13,264 INFO [Worker#STA_NP] NUnitDemo.SeleniumCommonTech.F_ReadExcel.ReadValue - Test-1
1 change: 1 addition & 0 deletions Logs/TEST.log.2019-01-29
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions Logs/TEST.log.2019-02-06
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions Logs/TEST.log.2019-02-18
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions Logs/TEST.log.2019-02-26
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions Logs/TEST.log.2019-03-13
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

15 changes: 15 additions & 0 deletions Logs/TEST.log.2019-03-14
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
2019-03-14 18:50:49,170 INFO [Worker#STA_NP] NUnitDemo.NUnit.stateDemo.TestMethod - ******Parent******
2019-03-14 18:50:49,184 INFO [Worker#STA_NP] NUnitDemo.NUnit.stateDemo.TestMethod - 0
2019-03-14 18:50:49,186 INFO [Worker#STA_NP] NUnitDemo.NUnit.stateDemo.TestMethod - 1
2019-03-14 18:50:49,187 INFO [Worker#STA_NP] NUnitDemo.NUnit.stateDemo.TestMethod - 1
2019-03-14 18:50:49,187 INFO [Worker#STA_NP] NUnitDemo.NUnit.stateDemo.TestMethod - 100
2019-03-14 18:50:49,187 INFO [Worker#STA_NP] NUnitDemo.NUnit.stateDemo.TestMethod - *****Child*******
2019-03-14 18:50:49,188 INFO [Worker#STA_NP] NUnitDemo.NUnit.stateDemo.TestMethod - 0
2019-03-14 18:50:49,188 INFO [Worker#STA_NP] NUnitDemo.NUnit.stateDemo.TestMethod - 2
2019-03-14 18:50:49,188 INFO [Worker#STA_NP] NUnitDemo.NUnit.stateDemo.TestMethod - 1
2019-03-14 18:50:49,188 INFO [Worker#STA_NP] NUnitDemo.NUnit.stateDemo.TestMethod - 50
2019-03-14 18:50:49,188 INFO [Worker#STA_NP] NUnitDemo.NUnit.stateDemo.TestMethod - 18:50:46.3178051
2019-03-14 18:50:49,188 INFO [Worker#STA_NP] NUnitDemo.NUnit.stateDemo.TestMethod - 18:50:46.3598062
2019-03-14 18:50:49,189 INFO [Worker#STA_NP] NUnitDemo.NUnit.stateDemo.TestMethod - Per: 150
2019-03-14 18:50:49,189 INFO [Worker#STA_NP] NUnitDemo.NUnit.stateDemo.TestMethod - Fail Test
2019-03-14 18:50:49,189 INFO [Worker#STA_NP] NUnitDemo.NUnit.stateDemo.TestMethod - Date: 14-03-2019
1 change: 1 addition & 0 deletions Logs/TEST.log.2019-03-23
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions Logs/TEST.log.2019-03-25
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

26 changes: 17 additions & 9 deletions NUnit/F_TestResult.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
using log4net;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NUnitDemo.TestDemo
{
[TestFixture]
public class TestResult
{
{
private static readonly ILog Log =
LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

[Test]
public void TestMethod()
public void TestMethod01()
{
Log.Info("This is test method 01");
}

[Test]
public void TestMethod02()
{
Log.Info("This is test method 02");
}

[Test]
public void TestMethod03()
{
int temp = 5;
Log.Info("Division Formula :" + temp / 0);
Expand All @@ -36,7 +43,8 @@ public void TestResultCheck()
else
{
Log.Info("Undefined TestContext.Status = " + TestContext.CurrentContext.Result.Outcome.Status.ToString());
}
}
}
}

}
}
15 changes: 15 additions & 0 deletions ParallelTestExecution/ParallelCommonClass.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;

namespace NUnitDemo.ParallelTestExecution
{
public class ParallelCommonClass
{
public IWebDriver driver;

public ParallelCommonClass()
{
driver = new ChromeDriver();
}
}
}
Loading