maven-cucumber-reporting插件在最新的5.3.0版本中未生成报告。

huangapple go评论93阅读模式
英文:

maven-cucumber-reporting plugin is not generating the report - in latest 5.3.0 version

问题

经过从GitHub复制粘贴Maven Cucumber报告的代码后,报告未生成在目标文件夹中。我不确定出了什么问题。我尝试使用Runner类和MVN控制台运行,但都没有在目标文件夹中生成报告。

POM文件和Runner文件看起来都正常,但可能有一些其他配置或依赖关系的问题。请确保您的项目结构和依赖项设置正确,并检查是否存在任何错误消息或日志,以帮助确定问题所在。您还可以尝试使用mvn clean test或mvn clean install来查看是否生成报告。

如果问题仍然存在,请提供更多详细信息,以便我可以提供更多帮助。

英文:

After copy pasting the code from github for maven cucumber reporting, the report is not generated in the target folder. I'm not sure what went missing. I tried with running with Runner class and MVN console both result did not generate the report in the target folder

POM file

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project xmlns="http://maven.apache.org/POM/4.0.0"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  5. <modelVersion>4.0.0</modelVersion>
  6. <groupId>MavenWeb</groupId>
  7. <artifactId>Coderio_Demo</artifactId>
  8. <version>0.0.1-SNAPSHOT</version>
  9. <name>Coderio_Demo</name>
  10. <!-- FIXME change it to the project's website -->
  11. <url>http://www.example.com</url>
  12. <properties>
  13. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  14. <maven.compiler.source>1.8</maven.compiler.source>
  15. <maven.compiler.target>1.8</maven.compiler.target>
  16. </properties>
  17. <dependencies>
  18. <dependency>
  19. <groupId>junit</groupId>
  20. <artifactId>junit</artifactId>
  21. <version>4.13</version>
  22. </dependency>
  23. <dependency>
  24. <groupId>org.seleniumhq.selenium</groupId>
  25. <artifactId>selenium-java</artifactId>
  26. <version>3.141.59</version>
  27. </dependency>
  28. <!-- https://mvnrepository.com/artifact/info.cukes/cucumber-java -->
  29. <dependency>
  30. <groupId>io.cucumber</groupId>
  31. <artifactId>cucumber-junit</artifactId>
  32. <version>6.4.0</version>
  33. </dependency>
  34. <dependency>
  35. <groupId>io.cucumber</groupId>
  36. <artifactId>cucumber-java</artifactId>
  37. <version>6.4.0</version>
  38. </dependency>
  39. <!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
  40. <dependency>
  41. <groupId>org.apache.poi</groupId>
  42. <artifactId>poi</artifactId>
  43. <version>4.1.2</version>
  44. </dependency>
  45. <!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
  46. <dependency>
  47. <groupId>org.apache.poi</groupId>
  48. <artifactId>poi-ooxml</artifactId>
  49. <version>4.1.2</version>
  50. </dependency>
  51. <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-picocontainer -->
  52. <dependency>
  53. <groupId>io.cucumber</groupId>
  54. <artifactId>cucumber-picocontainer</artifactId>
  55. <version>6.4.0</version>
  56. <scope>test</scope>
  57. </dependency>
  58. <dependency>
  59. <groupId>io.github.bonigarcia</groupId>
  60. <artifactId>webdrivermanager</artifactId>
  61. <version>3.0.0</version>
  62. </dependency>
  63. <dependency>
  64. <groupId>de.monochromata.cucumber</groupId>
  65. <artifactId>reporting-plugin</artifactId>
  66. <version>4.0.56</version>
  67. </dependency>
  68. <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-core -->
  69. <dependency>
  70. <groupId>io.cucumber</groupId>
  71. <artifactId>cucumber-core</artifactId>
  72. <version>6.4.0</version>
  73. </dependency>
  74. </dependencies>
  75. <build>
  76. <pluginManagement><!-- lock down plugins versions to avoid using Maven
  77. defaults (may be moved to parent pom) -->
  78. <plugins>
  79. <!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
  80. <plugin>
  81. <groupId>org.apache.maven.plugins</groupId>
  82. <artifactId>maven-surefire-plugin</artifactId>
  83. <version>2.18.1</version>
  84. <configuration>
  85. <testFailureIgnore>true</testFailureIgnore>
  86. </configuration>
  87. </plugin>
  88. <plugin>
  89. <groupId>net.masterthought</groupId>
  90. <artifactId>maven-cucumber-reporting</artifactId>
  91. <version>5.3.0</version>
  92. <executions>
  93. <execution>
  94. <id>execution</id>
  95. <phase>verify</phase>
  96. <goals>
  97. <goal>generate</goal>
  98. </goals>
  99. <configuration>
  100. <projectName>cucumber-jvm-example</projectName>
  101. <!-- optional, per documentation set this to "true" to bypass generation
  102. of Cucumber Reports entirely, defaults to false if not specified -->
  103. <skip>false</skip>
  104. <!-- output directory for the generated report -->
  105. <outputDirectory>target/customizereports/</outputDirectory>
  106. <!-- optional, defaults to outputDirectory if not specified -->
  107. <inputDirectory>target/cucumber-reports/cucumber.json</inputDirectory>
  108. <jsonFiles>
  109. <!-- supports wildcard or name pattern -->
  110. <param>**/*.json</param>
  111. </jsonFiles>
  112. <!-- optional, defaults to outputDirectory if not specified -->
  113. <classificationDirectory>${project.build.directory}/classifications</classificationDirectory>
  114. <classificationFiles>
  115. <!-- supports wildcard or name pattern -->
  116. <param>sample.properties</param>
  117. <param>other.properties</param>
  118. </classificationFiles>
  119. <parallelTesting>false</parallelTesting>
  120. <!-- optional, set true to group features by its Ids -->
  121. <mergeFeaturesById>false</mergeFeaturesById>
  122. <!-- optional, set true to get a final report with latest results
  123. of the same test from different test runs -->
  124. <mergeFeaturesWithRetest>false</mergeFeaturesWithRetest>
  125. <!-- optional, set true to fail build on test failures -->
  126. <checkBuildResult>true</checkBuildResult>
  127. </configuration>
  128. </execution>
  129. </executions>
  130. </plugin>
  131. </plugins>
  132. </pluginManagement>
  133. </build>
  134. </project>

and this my runnerfile

  1. package testRunner;
  2. import org.junit.runner.RunWith;
  3. //import cucumber.api.CucumberOptions;
  4. import io.cucumber.junit.Cucumber;
  5. import io.cucumber.junit.CucumberOptions;
  6. //import cucumber.api.junit.Cucumber;
  7. @RunWith(Cucumber.class)
  8. @CucumberOptions(features = "src/test/java/Features/", plugin = { "json:target/cucumber-reports/cucumber.json",
  9. "pretty", "html:target/html-report/cucumber-html-reports.html",
  10. "junit:target/cucumber-reports/cucumber.xml" }, glue = {
  11. "StepDefination" }, tags = "@LogOut1wwww1", monochrome = true)
  12. public class TestRunner {
  13. }

I ran through mvn clean verify

test case got executed, but reports were not generated

答案1

得分: 1

将您的pom.xml文件中的构建部分更改为以下内容:

  1. <build>
  2. <plugins>
  3. <plugin>
  4. <groupId>org.apache.maven.plugins</groupId>
  5. <artifactId>maven-surefire-plugin</artifactId>
  6. <version>2.18.1</version>
  7. <configuration>
  8. <testFailureIgnore>true</testFailureIgnore>
  9. </configuration>
  10. </plugin>
  11. <plugin>
  12. <groupId>net.masterthought</groupId>
  13. <artifactId>maven-cucumber-reporting</artifactId>
  14. <version>5.3.0</version>
  15. <executions>
  16. <execution>
  17. <id>report</id>
  18. <phase>integration-test</phase>
  19. <goals>
  20. <goal>generate</goal>
  21. </goals>
  22. <configuration>
  23. <outputDirectory>${project.build.directory}/cucumber-reports</outputDirectory>
  24. <jsonFiles>
  25. <jsonFile>**/*.json</jsonFile>
  26. </jsonFiles>
  27. <mergeFeaturesWithRetest>true</mergeFeaturesWithRetest>
  28. <mergeFeaturesById>true</mergeFeaturesById>
  29. <checkBuildResult>false</checkBuildResult>
  30. <skipEmptyJSONFiles>true</skipEmptyJSONFiles>
  31. </configuration>
  32. </execution>
  33. </executions>
  34. </plugin>
  35. </plugins>
  36. </build>
英文:

Change your build section in pom.xml to this

  1. &lt;build&gt;
  2. &lt;plugins&gt;
  3. &lt;plugin&gt;
  4. &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
  5. &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
  6. &lt;version&gt;2.18.1&lt;/version&gt;
  7. &lt;configuration&gt;
  8. &lt;testFailureIgnore&gt;true&lt;/testFailureIgnore&gt;
  9. &lt;/configuration&gt;
  10. &lt;/plugin&gt;
  11. &lt;plugin&gt;
  12. &lt;groupId&gt;net.masterthought&lt;/groupId&gt;
  13. &lt;artifactId&gt;maven-cucumber-reporting&lt;/artifactId&gt;
  14. &lt;version&gt;5.3.0&lt;/version&gt;
  15. &lt;executions&gt;
  16. &lt;execution&gt;
  17. &lt;id&gt;report&lt;/id&gt;
  18. &lt;phase&gt;integration-test&lt;/phase&gt;
  19. &lt;goals&gt;
  20. &lt;goal&gt;generate&lt;/goal&gt;
  21. &lt;/goals&gt;
  22. &lt;configuration&gt;
  23. &lt;outputDirectory&gt;${project.build.directory}/cucumber-reports&lt;/outputDirectory&gt;
  24. &lt;jsonFiles&gt;
  25. &lt;jsonFile&gt;**/*.json&lt;/jsonFile&gt;
  26. &lt;/jsonFiles&gt;
  27. &lt;mergeFeaturesWithRetest&gt;true&lt;/mergeFeaturesWithRetest&gt;
  28. &lt;mergeFeaturesById&gt;true&lt;/mergeFeaturesById&gt;
  29. &lt;checkBuildResult&gt;false&lt;/checkBuildResult&gt;
  30. &lt;skipEmptyJSONFiles&gt;true&lt;/skipEmptyJSONFiles&gt;
  31. &lt;/configuration&gt;
  32. &lt;/execution&gt;
  33. &lt;/executions&gt;
  34. &lt;/plugin&gt;
  35. &lt;/plugins&gt;
  36. &lt;/build&gt;

huangapple
  • 本文由 发表于 2020年8月14日 12:39:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/63406635.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定