在范围报告中编译所有测试套件的结果



范围报告仅报告上次运行的测试套件。

我已经用 10 种不同的套装设置了硒测试,按顺序运行.问题是范围报告仅记录最后一个套件的结果。我尝试了不同的方法来执行报告,以汇编所有结果。

代码结构: BaseSetUp 类 - 初始化驱动程序(OneTimeSetUp、SetUp、TearDown、OnetimeTearDown(

通用方法调用 - 继承自 BaseSetUp

页面对象页面 - 获取所有页面对象

TestSuit - 继承自常规方法。

我在 BaseSetUp 类中有这样的报告:

[OneTimeSetUp]
public void Setup()
{
try
{
extent = new ExtentReports();
var dir = AppDomain.CurrentDomain.BaseDirectory.Replace("\bin\Debug", "");
var htmlReporter = new ExtentHtmlReporter(dir + "\Test_Execution_Reports" + "\Automation_Report" + ".html");
extent.AddSystemInfo("Environment", "Xylect AT");
extent.AddSystemInfo("User Name", "Lucas");
extent = new ExtentReports();
extent.AttachReporter(htmlReporter);

}
catch (Exception e)
{
throw (e);
}}

[SetUp]
public void BeforeTest()
{
try
{
_test = extent.CreateTest(TestContext.CurrentContext.Test.Name);
}
catch (Exception e)
{
throw (e);
}
}

[TearDown]
public void AfterTest()
{
try
{
var status = TestContext.CurrentContext.Result.Outcome.Status;
var stacktrace = "" + TestContext.CurrentContext.Result.StackTrace + "";
var errorMessage = TestContext.CurrentContext.Result.Message;
Status logstatus;
switch (status)
{
case TestStatus.Failed:
logstatus = Status.Fail;
string screenShotPath = Capture(driver, TestContext.CurrentContext.Test.Name);
_test.Log(logstatus, "Test ended with " + logstatus + " – " + errorMessage);
_test.Log(logstatus, "Snapshot below: " + _test.AddScreenCaptureFromPath(screenShotPath));
break;
case TestStatus.Skipped:
logstatus = Status.Skip;
_test.Log(logstatus, "Test ended with " + logstatus);
break;
default:
logstatus = Status.Pass;
_test.Log(logstatus, "Test ended with " + logstatus);
break;
}

}
catch (Exception e)
{
throw (e);
}
}
[OneTimeTearDown]
public void TearDown()
{
try
{
//zip();
//Email();
extent.Flush();
driver.Close();
driver.Quit();
}
catch (Exception e)
{
throw (e);
}
}

我看到了几种将以前的报告添加到"新"创建的报告的方法,但我没有让它起作用。

其中一个测试套件中的测试用例示例

[TestCase(TestName = "01_LogIn"), Order(1)]
public void LogIn()
{
LogIn();
string loginAssert = HomePage.expLoginName.Text;
Assert.IsTrue(loginAssert.Contains("Hi, " + username + ""), "Login falied");
}

关于我应该如何前进的任何想法?

运行范围报表 V4

您只需点击此链接即可。我希望它能解决你的问题。

您必须创建 3 个类。

BaseFixture.cs
ExtentManager.cs
ExtentTestManager.cs

之后,您可以在每个测试类中初始化 BaseFixture。

[TestFixture, Parallelizable(ParallelScope.Fixtures)]
public class MemberLogInOut : BaseFixture

https://github.com/anshooarora/extentreports-csharp/tree/master/ExtentReports/ExtentReports.Tests/Parallel

最新更新