代码之家  ›  专栏  ›  技术社区  ›  Nagarjuna Reddy

Maven cucumber从eclipse报告,而不是根据此插件生成报告

  •  1
  • Nagarjuna Reddy  · 技术社区  · 7 年前

    尝试根据maven cucumber报告生成报告 Link to maven cucumber reporting

    对pom进行了必要的更改。xml文件,如下所述 tutorial on configuring reports

    但是报告是在简单的html文件中生成的,而不是按照cucumber报告生成的。

    pom。xml

       <pluginManagement>
                <plugins>
                    <plugin>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <version>3.3</version>
                        <configuration>
                            <source>1.${java.version}</source>
                            <target>1.${java.version}</target>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>2.20</version>
                        <configuration>
                            <!-- <testFailureIgnore>true</testFailureIgnore> -->
                            <includes>
                                <exclude>**/*RunCukesTest.java</exclude>
                                <!-- <include>**/*RunCukesTest.java</include> -->
                            </includes>
                            <!-- <excludes> <exclude>**/*RunCukesTest.java</exclude> </excludes> -->
                        </configuration>
                    </plugin>
                    <!-- This is for Cucumber Custom Report plug in we specify the configuration 
                        details under configuration tag. -->
                    <!-- http://startingwithseleniumwebdriver.blogspot.com/2016/05/custom-cucumber-reporting-using-maven.html -->
                     <plugin>
                        <groupId>net.masterthought</groupId>
                        <artifactId>maven-cucumber-reporting</artifactId>
                        <version>3.11.0</version>
                        <executions>
                            <execution>
                                <id>execution</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>generate</goal>
                                </goals>
                                <configuration>
                                    <projectName>CucumberReport</projectName>
                                    <outputDirectory>${project.build.directory}/site/cucumber-reports</outputDirectory>
                                    <!-- <cucumberOutput>${project.build.directory}/cucumber.json</cucumberOutput> -->
                                    <jsonFiles>
                                        <param>${project.build.directory}/cucumber.json</param>
                                    </jsonFiles>
                                    <!-- <parallelTesting>false</parallelTesting> -->
                                    <buildNumber>1</buildNumber>
                                    <checkBuildResult>false</checkBuildResult>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </pluginManagement>
    

    运行CUKESTEST。Java语言

    @RunWith(Cucumber.class)
    @CucumberOptions(
            features = {"classpath:features"},
            plugin = {"html:target/site/cucumber-pretty","json:target/cucumber.json"},
            tags = {"@currentTest"},
            glue={"helpers","stepDefinitions"},
            monochrome = true
            )
    public class RunCukesTest{
    
    }
    

    generated report

    与预期不同 expected report

    3 回复  |  直到 7 年前
        1
  •  1
  •   Jyotiprava Das    4 年前

    POM。XML::

          <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.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.21.0</version>
             <configuration>
                <testFailureIgnore>true</testFailureIgnore>
                <includes>
                <include>**/TestRunner.java</include>
                </includes>
             </configuration>
         </plugin>
    
    
       <plugin>
      <groupId>net.masterthought</groupId>
    <artifactId>maven-cucumber-reporting</artifactId>
    <version>4.5.0</version>
      <executions>
      <execution>
      <id>execution</id>
      <phase>test</phase>
    <goals>
     <goal>generate</goal>
     </goals>
    <configuration>
    <!--   <projectName>imademethink_cucumber_advanced_reporting</projectName>  -->
     <outputDirectory>${project.build.directory}/site/cucumber-reports-advanced</outputDirectory>
     <cucumberOutput>${project.build.directory}/cucumber/cucumber.json</cucumberOutput>
     <skippedFails>true</skippedFails>
     <enableFlashCharts>false</enableFlashCharts>
    <!--  <buildNumber>885</buildNumber> --> 
    <buildNumber>8.4.1.2</buildNumber>
     </configuration>
    </execution>
    </executions>
    </plugin>        
    
    
    
    
    
    
    
    
    
    
     </plugins>
     </build>
    
        2
  •  0
  •   Nagarjuna Reddy    7 年前

    所有配置都不错, 进行了两项更改。

    1. 远离的 pluginManagement pom中的标签
    2. 习惯于 cucumberOutput 输出目录,而不是 jsonFiles . 出于某种原因 J文件 正在生成重复的报告。

    pom文件,

          <build>
           <plugins>
              <plugin>
                 <artifactId>maven-compiler-plugin</artifactId>
                 <version>3.3</version>
                 <configuration>
                    <source>1.${java.version}</source>
                    <target>1.${java.version}</target>
                 </configuration>
              </plugin>
              <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-surefire-plugin</artifactId>
                 <version>2.20</version>
                 <configuration>
                    <includes>
                       <exclude>**/*RunCukesTest.java</exclude>
                    </includes>
                    <testFailureIgnore>true</testFailureIgnore>
                 </configuration>
              </plugin>
              <plugin>
                 <groupId>net.masterthought</groupId>
                 <artifactId>maven-cucumber-reporting</artifactId>
                 <version>3.13.0</version>
                 <executions>
                    <execution>
                       <id>execution</id>
                       <phase>verify</phase>
                       <goals>
                          <goal>generate</goal>
                       </goals>
                       <configuration>
                          <projectName>Simplify360 Automation Test Report</projectName>
                          <outputDirectory>${project.build.directory}/site/cucumber-reports</outputDirectory>                      
       <cucumberOutput>${project.build.directory}/cucumber.json</cucumberOutput>
                          <buildNumber>8.4.1.2</buildNumber>
                       </configuration>
                    </execution>
                 </executions>
              </plugin>
           </plugins>
        </build>
    
        3
  •  0
  •   Shubham Jain    6 年前

    您需要如下设置标志

    <checkBuildResult>true</checkBuildResult>
    

    在下面的问题URL中找到我的答案

    Reports are not generated when the build is failed in Maven Cucumber Reports