Hi,
Can anyone give me some advice on this please? I'm completely new to c# and VS but have some programming background. I'm trying to learn Selenium Extent Reports and have took this code example to understand how it works. When I use NuGet to instal extent reports in VS it shows it as AventStack.ExtentReports not RelevantCodes and when i paste the code in to validate it throws a number of errors on these lines, e.g:
using AventStack.ExtentReports;
extent = new ExtentReports(reportPath, true); //ExtentReports does not contain a constructor that has 2 arguments
extent.LoadConfig(projectPath + "extent-config.xml"); //ExtentReports does not contain a definition for LoadConfig
test = extent.StartTest("DemoReportPass"); //ExtentReports does not contain a definition for StartTest
test.Log(LogStatus.Pass, "Assert pass as False"); //ExtentReports does not contain a definition for Log
extent.EndTest(test);
extent.Close(); //ExtentReports does not contain a definition for Close
Any idea what is going on? I'm really struggling with the online help about Assemblies etc, i need it in newbies terms.
Any advice appreciated - cheers
Can anyone give me some advice on this please? I'm completely new to c# and VS but have some programming background. I'm trying to learn Selenium Extent Reports and have took this code example to understand how it works. When I use NuGet to instal extent reports in VS it shows it as AventStack.ExtentReports not RelevantCodes and when i paste the code in to validate it throws a number of errors on these lines, e.g:
using AventStack.ExtentReports;
extent = new ExtentReports(reportPath, true); //ExtentReports does not contain a constructor that has 2 arguments
extent.LoadConfig(projectPath + "extent-config.xml"); //ExtentReports does not contain a definition for LoadConfig
test = extent.StartTest("DemoReportPass"); //ExtentReports does not contain a definition for StartTest
test.Log(LogStatus.Pass, "Assert pass as False"); //ExtentReports does not contain a definition for Log
extent.EndTest(test);
extent.Close(); //ExtentReports does not contain a definition for Close
Any idea what is going on? I'm really struggling with the online help about Assemblies etc, i need it in newbies terms.
Any advice appreciated - cheers
C#:
using NUnit.Framework;
using NUnit.Framework.Interfaces;
using [COLOR=#ff0000][B]RelevantCodes[/B][/COLOR].ExtentReports;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ExtentReportsDemo
{
[TestFixture]
public class BasicReport
{
public [B]ExtentReports[/B] extent;
public[B]ExtentTest[/B] test;
[OneTimeSetUp]
public void StartReport()
{
string path = System.Reflection.Assembly.GetCallingAssembly().CodeBase;
string actualPath = path.Substring(0, path.LastIndexOf("bin"));
string projectPath = new Uri(actualPath).LocalPath;
string reportPath = projectPath + "Reports\\MyOwnReport.html";
[B][COLOR=#ff0000]extent = new ExtentReports(reportPath, true);[/COLOR][/B]
extent
.AddSystemInfo("Host Name", "Krishna")
.AddSystemInfo("Environment", "QA")
.AddSystemInfo("User Name", "Krishna Sakinala");
extent.LoadConfig(projectPath + "extent-config.xml");
}
[Test]
public void DemoReportPass()
{
test = extent.StartTest("DemoReportPass");
Assert.IsTrue(true);
test.Log(LogStatus.Pass, "Assert Pass as condition is True");
}
[Test]
public void DemoReportFail()
{
test = extent.StartTest("DemoReportFail");
Assert.IsTrue(false);
[COLOR=#ff0000][B]test.Log(LogStatus[/B][/COLOR].Pass, "Assert Fail as condition is False");
}
[TearDown]
public void GetResult()
{
var status = TestContext.CurrentContext.Result.Outcome.Status;
var stackTrace = "<pre>" + TestContext.CurrentContext.Result.StackTrace + "</pre>";
var errorMessage = TestContext.CurrentContext.Result.Message;
if (status == TestStatus.Failed)
{
test.Log(LogStatus.Fail, stackTrace + errorMessage);
}
extent.EndTest(test);
}
[OneTimeTearDown]
public void EndReport()
{
extent.Flush();
[B]extent.Close();[/B]
}
}
}