Java/cucumber 报告不是使用 masterthought 生成报告
Java/cucumber reporting not producing reports using masterthought
我一直在尝试整合 masterthought maven--cucumber-reporting
这样我就可以像宣传的那样生成关于 Jenkins 的漂亮报告。
我遵循了各个站点(包括 damienfremont.com 帖子)中的配置说明,但我的实施没有产生任何报告。
Whosebug 上的类似帖子没有提供答案。
CucumberTestRunner.java
@RunWith(Cucumber.class)
@CucumberOptions(
glue = "xxx.yyy.zzz.cucumber",
features = "src/test/resources/features",
snippets = SnippetType.CAMELCASE,
tags = {"@aaa", "@bbb"},
plugin = {"json:target/cucumber.json", "html:target/site/cucumber-pretty"}
)
public class CucumberTestRunner {}
pom.xml
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>4.2.0</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>4.2.0</version>
</dependency>
<dependency>
<groupId>net.masterthought</groupId>
<artifactId>cucumber-reporting</artifactId>
<version>4.4.0</version>
</dependency>
Other dependencies - Spring, database, logging, etc
<dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.5.0</version>
<executions>
<execution>
<phase>integration-test</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<classpathScope>test</classpathScope>
<mainClass>cucumber.api.cli.Main</mainClass>
<arguments>
<argument>--glue</argument><argument>xxx.yyy.zzz.cucumber</argument>
<argument>--snippets</argument><argument>camelcase</argument>
<argument>--plugin</argument><argument>html:target/cucumber.html</argument>
<argument>src/test/resources</argument> <!-- features location -->
</arguments>
</configuration>
<\execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.21.0</version>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
<plugin>
<groupId>net.masterthought</groupId>
<artifactId>maven--cucumber-reporting</artifactId>
<version>4.4.0</version>
<executions>
<execution>
<id>execution</id>
<phase>verify</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<projectName>ExecuteReporting</projectname>
<outputDirectory>${project.build.directory}/site/cucumber-reports</outputDirectory>
<cucumberOutput>${project.build.directory}/cucumber-jason</cucumberOutput>
<checkBuildResult>cucumber.api.cli.Main</checkBuildResult>
</configuration>
<\execution>
</executions>
</plugin>
</plugins>
</build>
结果:
来自 intelliJ 的 运行ning CucumberTestRunner.java 创建 target/cucumber.json 和 target/site/cucumber-pretty/index.html 等
运行ning mvn verify -Dcucumber.options="--tags @aaa --tags @bbb"
创建 target/cucumber.html/index.html
等(在 pom 中指定)
因此正在制作原生的 surefire 报告,但我没有得到大师级的输出。
当我通过 Jenkins 运行 mvn build
安装了 cucumber-reports.hfi
插件时,我得到 "net.masterthought.cucumber.ValidationException: Nonereport
文件已添加!”自 mvn 作业以来这是有意义的不生产 reports.password
我查看了其他 Whosebug 问题,但看不出我的代码有什么问题。非常感谢任何帮助。
我也遇到了同样的错误。然后我使用下面的代码而不是使用 pom.xml
net.masterthought
插件。它工作并生成了报告。
但是,我使用的是 TestNG。因此,您必须使用 @After Annotation
.
检查它是否与 JUnit 一起工作
@AfterSuite
public void generateReport() {
File reportOutputDirectory = new File("target"); //
List<String> jsonFiles = new ArrayList<String>();
jsonFiles.add("target/cucumber.json");
String projectName = "Your Sample Project Name";
String buildNumber = "1.0";
Configuration configuration = new Configuration(reportOutputDirectory,
projectName);
configuration.setRunWithJenkins(true);
configuration.setBuildNumber(buildNumber);
ReportBuilder reportBuilder = new ReportBuilder(jsonFiles, configuration);
reportBuilder.generateReports();
}
问题已排序:在 pom.xml
、exec-maven-plugin
中,我需要
json:${project.build.directory}/somewhere/for/reports
的插件参数
蓬松的 Jenkins 报告需要 json 文件。还需要确保 Jenkins Cucumber 报告配置中指定的目录与 pom.xml 文件中指定的目录一致。
不需要net.masterthought plugin
。
我一直在尝试整合 masterthought maven--cucumber-reporting
这样我就可以像宣传的那样生成关于 Jenkins 的漂亮报告。
我遵循了各个站点(包括 damienfremont.com 帖子)中的配置说明,但我的实施没有产生任何报告。
Whosebug 上的类似帖子没有提供答案。
CucumberTestRunner.java
@RunWith(Cucumber.class)
@CucumberOptions(
glue = "xxx.yyy.zzz.cucumber",
features = "src/test/resources/features",
snippets = SnippetType.CAMELCASE,
tags = {"@aaa", "@bbb"},
plugin = {"json:target/cucumber.json", "html:target/site/cucumber-pretty"}
)
public class CucumberTestRunner {}
pom.xml
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>4.2.0</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>4.2.0</version>
</dependency>
<dependency>
<groupId>net.masterthought</groupId>
<artifactId>cucumber-reporting</artifactId>
<version>4.4.0</version>
</dependency>
Other dependencies - Spring, database, logging, etc
<dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.5.0</version>
<executions>
<execution>
<phase>integration-test</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<classpathScope>test</classpathScope>
<mainClass>cucumber.api.cli.Main</mainClass>
<arguments>
<argument>--glue</argument><argument>xxx.yyy.zzz.cucumber</argument>
<argument>--snippets</argument><argument>camelcase</argument>
<argument>--plugin</argument><argument>html:target/cucumber.html</argument>
<argument>src/test/resources</argument> <!-- features location -->
</arguments>
</configuration>
<\execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.21.0</version>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
<plugin>
<groupId>net.masterthought</groupId>
<artifactId>maven--cucumber-reporting</artifactId>
<version>4.4.0</version>
<executions>
<execution>
<id>execution</id>
<phase>verify</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<projectName>ExecuteReporting</projectname>
<outputDirectory>${project.build.directory}/site/cucumber-reports</outputDirectory>
<cucumberOutput>${project.build.directory}/cucumber-jason</cucumberOutput>
<checkBuildResult>cucumber.api.cli.Main</checkBuildResult>
</configuration>
<\execution>
</executions>
</plugin>
</plugins>
</build>
结果: 来自 intelliJ 的 运行ning CucumberTestRunner.java 创建 target/cucumber.json 和 target/site/cucumber-pretty/index.html 等
运行ning mvn verify -Dcucumber.options="--tags @aaa --tags @bbb"
创建 target/cucumber.html/index.html
等(在 pom 中指定)
因此正在制作原生的 surefire 报告,但我没有得到大师级的输出。
当我通过 Jenkins 运行 mvn build
安装了 cucumber-reports.hfi
插件时,我得到 "net.masterthought.cucumber.ValidationException: Nonereport
文件已添加!”自 mvn 作业以来这是有意义的不生产 reports.password
我查看了其他 Whosebug 问题,但看不出我的代码有什么问题。非常感谢任何帮助。
我也遇到了同样的错误。然后我使用下面的代码而不是使用 pom.xml
net.masterthought
插件。它工作并生成了报告。
但是,我使用的是 TestNG。因此,您必须使用 @After Annotation
.
@AfterSuite
public void generateReport() {
File reportOutputDirectory = new File("target"); //
List<String> jsonFiles = new ArrayList<String>();
jsonFiles.add("target/cucumber.json");
String projectName = "Your Sample Project Name";
String buildNumber = "1.0";
Configuration configuration = new Configuration(reportOutputDirectory,
projectName);
configuration.setRunWithJenkins(true);
configuration.setBuildNumber(buildNumber);
ReportBuilder reportBuilder = new ReportBuilder(jsonFiles, configuration);
reportBuilder.generateReports();
}
问题已排序:在 pom.xml
、exec-maven-plugin
中,我需要
json:${project.build.directory}/somewhere/for/reports
蓬松的 Jenkins 报告需要 json 文件。还需要确保 Jenkins Cucumber 报告配置中指定的目录与 pom.xml 文件中指定的目录一致。
不需要net.masterthought plugin
。