Maven 不输出 junit CHECKSTYLE 报告
Maven not outputting junit CHECKSTYLE report
默认配置后,maven 仅输出源 类 的 Checkstyle report,而非 Junit 测试 类。注意我不是在寻找 surefire 测试报告输出。
来自 pom.xml:
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.17</version>
<reportSets>
<reportSet>
<reports>
<report>checkstyle</report>
</reports>
</reportSet>
</reportSets>
<configuration>
<configLocation>src/main/resources/apcheckstyle.xml</configLocation>
<module name="LineLength">
<property name="max" value="120"/>
</module>
</configuration>
</plugin>
</plugins>
我将 junit 的依赖范围从 test 更改为 compile:
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>compile</scope>
</dependency>
Maven 配置为使用 mvn 站点插件生成 checkstyle 报告。
我尝试将用户 属性 includeTestResources 添加为 true,但这没有帮助。文档上说默认值是true,所以我把它拿出来了。
这里是 checkstyle 生成过程中的 maven 输出。
来自 java文档:
Generating C:\Users\Administrator\Projects\lht657aws\target\site\testapidocs\help-doc.html...
checkstyle 插件运行:
[INFO] Generating "Checkstyle" report --- maven-checkstyle-plugin:2.17
[INFO] There are 210 errors reported by Checkstyle 6.11.2 with src/main/resources/apcheckstyle.xml ruleset.
下面的问题是-?正在处理 src 下的所有 java,只是跳过测试中的 java:
[WARNING] Unable to locate Source XRef to link to - DISABLED
checkstyle后,maven项目信息报告开始
[INFO] Generating "Dependencies" report --- maven-project-info-reports-plugin:2.9
将 Maven Surefire Report 插件添加到您的 pom XML
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<outputDirectory>path/to/the/report</outputDirectory>
</configuration>
</plugin>
并将目标 surefire-report:report
添加到您的 Maven 调用中
在此处查看文档:Maven Surefire Report Plugin
编辑
我误解了这个问题,请尝试将此部分与所需的配置添加到您的 pom。
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.17</version>
<reportSets>
<reportSet>
<id>main_checks</id>
<reports>
<report>checkstyle</report>
</reports>
<configuration>
<sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
<includeTestSourceDirectory>false</includeTestSourceDirectory>
<configLocation>config/maven_checks.xml</configLocation>
<outputDirectory>${project.reporting.outputDirectory}/main-checks/</outputDirectory>
</configuration>
</reportSet>
<reportSet>
<id>test_checks</id>
<reports>
<report>checkstyle</report>
</reports>
<configuration>
<sourceDirectory></sourceDirectory>
<testSourceDirectory>${project.build.testSourceDirectory}</testSourceDirectory>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
<configLocation>config/sun_checks.xml</configLocation>
<outputDirectory>${project.reporting.outputDirectory}/test-checks/</outputDirectory>
</configuration>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
Maven sure fire 插件用于生成测试报告。请在此处查看附加文档:
http://maven.apache.org/surefire/maven-surefire-report-plugin/
您需要在 POM.xml 中包含此插件并提供创建报告的路径(通常是项目中的目录)。在进行构建时,请确保包含此目标。
默认配置后,maven 仅输出源 类 的 Checkstyle report,而非 Junit 测试 类。注意我不是在寻找 surefire 测试报告输出。
来自 pom.xml:
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.17</version>
<reportSets>
<reportSet>
<reports>
<report>checkstyle</report>
</reports>
</reportSet>
</reportSets>
<configuration>
<configLocation>src/main/resources/apcheckstyle.xml</configLocation>
<module name="LineLength">
<property name="max" value="120"/>
</module>
</configuration>
</plugin>
</plugins>
我将 junit 的依赖范围从 test 更改为 compile:
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>compile</scope>
</dependency>
Maven 配置为使用 mvn 站点插件生成 checkstyle 报告。 我尝试将用户 属性 includeTestResources 添加为 true,但这没有帮助。文档上说默认值是true,所以我把它拿出来了。
这里是 checkstyle 生成过程中的 maven 输出。
来自 java文档:
Generating C:\Users\Administrator\Projects\lht657aws\target\site\testapidocs\help-doc.html...
checkstyle 插件运行:
[INFO] Generating "Checkstyle" report --- maven-checkstyle-plugin:2.17
[INFO] There are 210 errors reported by Checkstyle 6.11.2 with src/main/resources/apcheckstyle.xml ruleset.
下面的问题是-?正在处理 src 下的所有 java,只是跳过测试中的 java:
[WARNING] Unable to locate Source XRef to link to - DISABLED
checkstyle后,maven项目信息报告开始
[INFO] Generating "Dependencies" report --- maven-project-info-reports-plugin:2.9
将 Maven Surefire Report 插件添加到您的 pom XML
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<outputDirectory>path/to/the/report</outputDirectory>
</configuration>
</plugin>
并将目标 surefire-report:report
添加到您的 Maven 调用中
在此处查看文档:Maven Surefire Report Plugin
编辑
我误解了这个问题,请尝试将此部分与所需的配置添加到您的 pom。
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.17</version>
<reportSets>
<reportSet>
<id>main_checks</id>
<reports>
<report>checkstyle</report>
</reports>
<configuration>
<sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
<includeTestSourceDirectory>false</includeTestSourceDirectory>
<configLocation>config/maven_checks.xml</configLocation>
<outputDirectory>${project.reporting.outputDirectory}/main-checks/</outputDirectory>
</configuration>
</reportSet>
<reportSet>
<id>test_checks</id>
<reports>
<report>checkstyle</report>
</reports>
<configuration>
<sourceDirectory></sourceDirectory>
<testSourceDirectory>${project.build.testSourceDirectory}</testSourceDirectory>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
<configLocation>config/sun_checks.xml</configLocation>
<outputDirectory>${project.reporting.outputDirectory}/test-checks/</outputDirectory>
</configuration>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
Maven sure fire 插件用于生成测试报告。请在此处查看附加文档:
http://maven.apache.org/surefire/maven-surefire-report-plugin/
您需要在 POM.xml 中包含此插件并提供创建报告的路径(通常是项目中的目录)。在进行构建时,请确保包含此目标。