java—如何在运行时将“plugin”参数传递给@cucumberoptions

yvfmudvl  于 2021-07-03  发布在  Java
关注(0)|答案(0)|浏览(345)

目标:我们的项目在eclipse上使用cucumber+java+slenium+junitmaven模块来执行ui自动化。在整个测试运行之后,将触发一个带有状态报告的自动邮件。
目标:将报告保存在临时位置,sendreport(path)方法将从中获取报告并通过邮件发送。我需要将临时文件夹的位置传递到@cucumberoptions(plugin=“”),以便在该位置创建报告。
问题/问题:无法将临时文件夹的位置设置到@cucumberoptions中
请检查下面的代码,并感谢任何帮助。谢谢。

@RunWith(Cucumber.class)
@CucumberOptions(
    format = { "html:target/cucumber-report", "json:target/uiauto-report/1.json" },
    features = "features/icg-uiauto-test-features",
    glue = "uiauto/common/glue",
    tags = {"@uiauto-status-report"}, 
    plugin = { "com.vimalselvam.cucumber.listener.ExtentCucumberFormatter:UIAUTO-Report/uiauto-status-report.html"}
)
public class UiAutoTest {

public RunWebapiTest() {}    

@Rule
public static TemporaryFolder folder = new TemporaryFolder();
private static String reportPath;

@BeforeClass
public static void tempFolder() throws IOException, IllegalStateException {
     TemporaryFolder folder = new TemporaryFolder();

     log.info("Creating test folder...");
     folder.create();
     File createdFolder= folder.newFolder("UITestReport");

   if (createdFolder.exists()) {
    log.info("Test Folder Created...");
    File testFile = folder.newFile(uiautotest); 
    testFile.createNewFile();
    reportPath = testFile.getAbsolutePath();

    log.info(uiautotest+"'s path : "+reportPath);
   } else {
    log.info("Folder unavailable.");
   }      
}

 @AfterClass
public static void prepareExtentReport() {      

    try {
        Reporter.loadXMLConfig(new File("src/main/resources/extent-config.xml"));
        Reporter.getExtentHtmlReport();
        log.info("Report preparation completed!");
        SendSanityReport.sendReport(reportPath);    // Sends report over mail
    } catch (Exception e) {
        e.printStackTrace();
    }
}

}

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题