我需要使用 Extent Report 和 Junit 创建一个报告,我开发了以下代码,但是当我运行它时,没有创建 HTML 文件(报告)。
public class Steps extends Execute {
private static ExtentHtmlReporter htmlReporter;
private static ExtentReports extentReport;
private static ExtentTest extentTest;
@BeforeMethod
public void beforeCenario(Scenario cenario) {
if(extentReport == null) {
extentReport = new ExtentReports();
htmlReporter = new
ExtentHtmlReporter("src/test/resources/htmlReporter.html");
extentReport.attachReporter(htmlReporter);
}
extentTest = extentReport.createTest(cenario.getId());
}
@Test
@Given("acessei a url do portal")
public void AcessoUrl() {
Execute Executar = new Execute();
Executar.abrirBrowser();
}
@AfterMethod
public void afterCenario(Scenario cenario) {
extentTest.log(Status.PASS, "Cenario "+ cenario.getName()+ "executado com sucesso!");
extentReport.flush();
}
我试过了@Before
,但它没有运行我的代码,我收到了这条消息:
钩子前失败:Steps.beforeCenario(Scenario) 消息:java.lang.NoClassDefFoundError: freemarker/template/TemplateModelException
freemarker 依赖于我的 pom.XML:
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.23</version>
</dependency>
我也试过@BeforeTest
了,它运行我的代码,但它也没有创建 HTML 文件。
你能帮我吗?谢谢 =)