如何使用Cluecumber生成报告? [英] How to use Cluecumber to generate reports?
问题描述
如何使用 Cluecumber 生成用于自动化测试的报告.
How to generate reports for automation tests using Cluecumber.
推荐答案
发布并回答我自己的问题,以防可能对其他人有帮助.
Posting and answering my own question in case it may be helpful to someone else.
-
将Cluecumber插件添加到pom文件中.在撰写本文时,最新版本是2.3.4,但是可以检查在这里进行更新.
<plugin>
<groupId>com.trivago.rta</groupId>
<artifactId>cluecumber-report-plugin</artifactId>
<version>2.3.4</version>
<executions>
<execution>
<id>report</id>
<phase>post-integration-test</phase>
<goals>
<goal>reporting</goal>
</goals>
</execution>
</executions>
<configuration>
<sourceJsonReportDirectory>${project.build.directory}/cucumber-report</sourceJsonReportDirectory>
<generatedHtmlReportDirectory>${project.build.directory}/generated-report
</generatedHtmlReportDirectory>
</configuration>
</plugin>
将json:target/cucumber-report/cucumber.json
添加到Runner
中,这样您将获得以下内容:
Add json:target/cucumber-report/cucumber.json
to your Runner
, so you would have something like this:
import io.cucumber.junit.CucumberOptions;
import io.cucumber.junit.Cucumber;
import org.junit.runner.RunWith;
@RunWith(Cucumber.class)
@CucumberOptions(
features = {"."},
glue = {"my_folder.steps", "my_folder.hooks"},
monochrome = true,
plugin = {"json:target/cucumber-report/cucumber.json"}
)
public class MainRunner {
}
PS:不需要html目标
- 运行测试,完成此操作后,导航到终端并键入
mvn cluecumber-report:reporting
(完全相同).
- Run your tests and once this is done navigate to the terminal and type
mvn cluecumber-report:reporting
(exactly as it is).
这将生成一个仅在运行此命令时显示的文件夹.它位于target
文件夹下,并将被称为generated-report
.您应该在其中找到报告所在的index.html
文件(右键单击并在浏览器中将其打开以查看它).
This will generate a folder that only appears when this command is run. It'll be under target
folder and will be called generated-report
. There you should find the index.html
file where your reports should be (right click and open it on a browser to see it).
这篇关于如何使用Cluecumber生成报告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!