Я пробую ExtentReports в Visual Studio C#. Когда я запускаю тестовый пример, файл отчета HTML не генерируется. Я не уверен, что не так в моем коде.
Я думаю, что папка «Путь к моим отчетам» верен.
In Solution Explorer я создал папку с названием «Отчеты», и я бы хотел, чтобы файл отчета был создан здесь.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"));
string projectPath = new Uri(actualPath).LocalPath; // project path of your solution
string reportPath = projectPath + "Reports\\testreport.html";
// 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", "localhost")
.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 = ""+TestContext.CurrentContext.Result.StackTrace+"";
var errorMessage = TestContext.CurrentContext.Result.Message;
if (status == NUnit.Framework.Interfaces.TestStatus.Failed)
{
test.Log(LogStatus.Fail, stackTrace + errorMessage);
}
extent.EndTest(test);
}
[OneTimeTearDown]
public void EndReport()
{
extent.Flush();
extent.Close();
}
}
}
< /code>
Нет ошибок, когда я строю решение. Тест работает нормально, но TestReport.html не генерируется. < /p>
Спасибо, Riaz < /p>
Подробнее здесь: https://stackoverflow.com/questions/409 ... -being-gen