英文:
How to generate Cucumber Report using Main.run method?
问题
我正在使用Cucumber for Java。
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>6.1.1</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>6.1.1</version>
</dependency>
我不是使用"Cucumber Options"来配置步骤或特性。我正在使用"Main.run"方法。
String feature = "/resources/service1/feature1.feature";
Main.run(new String[]{"--glue", "example.aop.testing.steps", feature}
, Thread.currentThread().getContextClassLoader())
一切都正常工作,但我想生成一个带有结果的报告。我正在阅读有关此的信息,要配置它,我需要使用"Cucumber Options",就像这样:
@RunWith(Cucumber.class)
@Cucumber.Options(format = {"pretty", "html:target/cucumber"})
public class runTest { }
如何使用这种方法进行配置?
英文:
I am using Cucumber for Java
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>6.1.1</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>6.1.1</version>
</dependency>
I am not using Cucumber Options
to configure the step or feature to use. I am using Main.run
method
String feature = "/resources/service1/feature1.feature"
Main.run(new String[]{"--glue", "example.aop.testing.steps", feature}
, Thread.currentThread().getContextClassLoader())
Everything it's working find but I would like to generate a report with the result. I was reading about it and to configura it I need to use Cucumber Options
, like this:
@RunWith(Cucumber.class)
@Cucumber.Options(format = {"pretty", "html:target/cucumber"})
public class runTest { }
How can I configure it using that approach??
答案1
得分: 2
你可以在添加glue和feature的同一数组中使用其他选项,如下所示:
String[] commonOptions = {
"--glue",
"com.test.automation.stepdefinitions",
"--tags",
"@foo",
"--plugin",
"pretty",
"--plugin",
"html:" + reportFolderPath + "/html",
"--plugin",
"json:" + reportFolderPath + "/cucumber.json",
FEATURE_FILE_PATH
};
英文:
You can use other options in the same array you are adding your glue and feature like below
String[] commonOptions = {
"--glue",
"com.test.automation.stepdefinitions",
"--tags",
"@foo",
"--plugin",
"pretty",
"--plugin",
"html:"+reportFolderPath+"/html",
"--plugin",
"json:"+reportFolderPath+"/cucumber.json",
FEATURE_FILE_PATH
};
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论