Я работал с ExtentReports с селеном в Visual Studio C #, я запускал тематические тесты, но файл отчета .html не генерируется в папке отчета, которую я создал в обозревателе решений.Я не знаю, в чем проблема, я изменил путь к файлу отчета, чтобы проверить, и он все еще не генерирует.Вот мой код:
<code> using NUnit.Framework;
using RelevantCodes.ExtentReports;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ExtentReportsDemo
{
[TestFixture]
public class BasicReport
{
public ExtentReports extent;
public ExtentTest test;
[OneTimeSetUp]
public void StartReport()
{
string pth =
System.Reflection.Assembly.GetCallingAssembly().CodeBase;
string actualPath = pth.Substring(0, pth.LastIndexOf("bin"));
Console.WriteLine("actual" + actualPath);
string projectPath = new Uri(actualPath).LocalPath; // project path
of your solution
//Console.WriteLine("project" + projectPath);
string reportPath = projectPath + "Reports\\testreport.html";
Console.WriteLine("report" + reportPath);
// true if you want to append data to the report. Replace existing
report with new report. False to create new report each time
extent = new ExtentReports(reportPath, false);
extent.AddSystemInfo("Host Name", "MININT-F36S5EH")
.AddSystemInfo("Environment", "QA")
.AddSystemInfo("User Name", "testUser");
extent.LoadConfig(projectPath + "extent-config.xml");
}
[Test]
public void DemoReportPass()
{
test = extent.StartTest("DemoReportPass");
Assert.IsTrue(true);
test.Log(LogStatus.Pass, "Assert Pass as consition is true");
}
[Test]
public void DemoReportFail()
{
test = extent.StartTest("DemoReportPass");
Assert.IsTrue(false);
test.Log(LogStatus.Fail, "Assert Pass as condition is false");
}
[TearDown]
public void GetResult()
{
var status = TestContext.CurrentContext.Result.Outcome.Status;
var stackTrace = "<pre>" +
TestContext.CurrentContext.Result.StackTrace + "
"; var errorMessage = TestContext.CurrentContext.Result.Message; if (status == NUnit.Framework.Interfaces.TestStatus.Failed) {test.Log (LogStatus.Fail, stackTrace +)errorMessage);} экстент.EndTest (тест);} [OneTimeTearDown] public void EndReport () {deg.Flush (); экстент.xml:
<?xml version="1.0" encoding="UTF-8"?>
<extentreports>
<configuration>
<!-- report theme -->
<!-- standard, dark -->
<theme>standard</theme>
<!-- document encoding -->
<!-- defaults to UTF-8 -->
<encoding>UTF-8</encoding>
<!-- protocol for script and stylesheets -->
<!-- defaults to https -->
<protocol>https</protocol>
<!-- title of the document -->
<documentTitle>ExtentReports 2.0</documentTitle>
<!-- report name - displayed at top-nav -->
<reportName>Automation Report</reportName>
<!-- report headline - displayed at top-nav, after reportHeadline -->
<reportHeadline></reportHeadline>
<!-- global date format override -->
<!-- defaults to yyyy-MM-dd -->
<dateFormat>yyyy-MM-dd</dateFormat>
<!-- global time format override -->
<!-- defaults to HH:mm:ss -->
<timeFormat>HH:mm:ss</timeFormat>
<!-- custom javascript -->
<scripts>
<![CDATA[
$(document).ready(function() {
});
]]>
</scripts>
<!-- custom styles -->
<styles>
<![CDATA[
]]>
</styles>
</configuration>