问题描述
我使用ExtentReports 5.0.3版本。 我有一个报告的基类
public class Reports
{
protected static ExtentTest test;
protected static ExtentReports extent;
protected static ExtentSparkReporter reportAll;
protected static ExtentSparkReporter reportFail;
@BeforeAll
static void setUpBeforeClass()
{
extent = new ExtentReports();
reportAll = new ExtentSparkReporter(System.getProperty("user.dir")+"\\AllResults.html")
.viewConfigurer()
.viewOrder()
.as(new ViewName[] { ViewName.DASHBOARD,ViewName.TEST })
.apply();
reportFail = new ExtentSparkReporter(System.getProperty("user.dir")+"\\FailedResults.html")
.filter()
.statusFilter()
.as(new Status[] { Status.FAIL })
.apply();
extent.attachReporter(reportAll,reportFail);
}
@AfterAll
static void oneTimeTearDown()
{
extent.flush();
}
}
我有一个简单的测试套件
@RunWith(JUnitPlatform.class)
@SelectClasses({
SumTest.class,HelloTest.class
})
class SmokeUnit
{}
每个测试都会扩展Reports类。 例如,
public class SumTest extends Reports
{
private Sum sum;
@BeforeEach
void setUp()
{
sum = new Sum();
}
@Test
void addition(TestInfo info)
{
test = extent.createTest("addition");
assertEquals(2,sum.sumInt(1,1));
test.log(Status.PASS,"1 + 1 = 2");
}
}
当我运行此套件时,ExtentReports仅为 HelloTest 创建报告。如果我切换测试类的顺序,则会为 SumTest 类创建报告。始终是套房的最后一堂课。请帮忙。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)