Java /黄瓜报告不使用MasterThought生成报告

时间:2019-02-20 12:21:55

标签: java maven cucumber

我一直在尝试整合大师思想的专家-黄瓜报告,以便我可以像宣传的那样对詹金斯产生漂亮的报告。 我在各个站点(包括damienfremont.com帖子)都遵循了配置说明,但是我的实现未生成任何报告。 StackOverflow上的类似帖子未提供答案。

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运行CucumberTestRunner.java会创建target / cucumber.json和target / site / cucumber-pretty / index.html等

运行mvn verify -Dcucumber.options =“-tags @aaa --tags @bbb”创建target / cucumber.html / index.html等(在pom中指定)

因此正在生成本机的surefire报告,但我没有掌握精通的输出。

当我通过Jenkins运行mvn构建,并安装了cucumber-reports.hfi插件时,我得到“ net.masterthought.cucumber.ValidationException:未添加报告文件!”这很有意义,因为mvn作业不会生成报告。密码

我查看了其他StackOverflow问题,但看不到我的代码有什么问题。任何帮助表示赞赏。

2 个答案:

答案 0 :(得分:0)

我也遇到了同样的错误。然后,我使用下面的代码,而不是使用pom.xml'net.masterthought'插件。它工作并生成了报告。 但是,我正在使用TestNG。因此,您将必须使用@After注释检查它是否与JUnit兼容。

select t.*
from t
where doc_rule like '% & %';

答案 1 :(得分:0)

已排序的问题:在pom.xml,exec-maven-plugin中,我需要     json的插件参数:$ {project.build.directory} / somewhere / for / reports

蓬松的Jenkins报告需要json文件。还需要确保Jenkins Cucumber报告配置中指定的目录与pom.xml文件中指定的目录一致。

不需要net.masterthought插件。