简体   繁体   English

JACoCo/surefire-plugin 找不到要运行的测试

[英]JACoCo/surefire-plugin does not find tests to run

All my tests are located in src/test/java/... with java marked as a test source folder.我所有的测试都位于 src/test/java/... java 标记为测试源文件夹。 They are also all named as ***Test so Surefire plugin should be finding them.它们也都被命名为 ***Test 所以 Surefire 插件应该可以找到它们。

However my maven verify fails as all my test coverage is at 0%.但是我的 maven 验证失败,因为我的所有测试覆盖率都是 0%。 I have 20 tests which should cover all of my non-excluded classes and they all pass when I do run them in my IntelliJ.我有 20 个测试应该涵盖我所有的非排除类,并且当我在 IntelliJ 中运行它们时它们都通过了。 When I run maven test or maven verify my tests aren't being run.当我运行 maven 测试或 maven 验证我的测试没有运行。 I'm not sure why.我不确定为什么。

<plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.8.6</version>
                <executions>
                    <execution>
                        <id>default-prepare-agent</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>default-report</id>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>jacoco-check</id>
                        <goals>
                            <goal>check</goal>
                        </goals>
                        <configuration>
                            <excludes>
                                ...
                            </excludes>
                            <rules>
                                <rule>
                                    <element>CLASS</element>
                                    <limits>
                                        <limit>
                                            <counter>LINE</counter>
                                            <value>COVEREDRATIO</value>
                                            <minimum>80%</minimum>
                                        </limit>
                                        <limit>
                                            <counter>BRANCH</counter>
                                            <value>COVEREDRATIO</value>
                                            <minimum>80%</minimum>
                                        </limit>
                                    </limits>
                                </rule>
                            </rules>
                        </configuration>
                    </execution>
                    <execution>
                        <id>report</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.0.0-M5</version>
            </plugin>
----------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- jacoco-maven-plugin:0.8.6:prepare-agent (default-prepare-agent) @ *-*-service ---
[INFO] surefireArgLine set to "-javaagent:C:\\Users\\*\\.m2\\repository\\org\\jacoco\\org.jacoco.agent\\0.8.6\\org.jacoco.agent-0.8.6-runtime.jar=destfile=C:\\Users\\*\\OneDrive\\Documents\\IntelliJ Projects\\*-*-service\\*-*-service\\target\\jacoco.exec,append=true"
[INFO] 
[INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ *-*-service ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 1 resource
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ *-*-service ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:3.2.0:testResources (default-testResources) @ *-*-service ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] skip non existing resourceDirectory C:\Users\*\OneDrive\Documents\IntelliJ Projects\*-*-service\*-*-service\src\test\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ *-*-service ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:3.0.0-M5:test (default-test) @ *-*-service ---
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[ERROR] Java HotSpot(TM) 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.
[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[INFO] 
[INFO] --- jacoco-maven-plugin:0.8.6:report (report) @ *-*-service ---
[INFO] Loading execution data file C:\Users\*\OneDrive\Documents\IntelliJ Projects\*-*-service\*-*-service\target\jacoco.exec
[INFO] Analyzed bundle '*-*-service' with 19 classes
[INFO] 
[INFO] --- maven-jar-plugin:3.2.0:jar (default-jar) @ *-*-service ---
[INFO] 
[INFO] --- spring-boot-maven-plugin:2.4.4:repackage (repackage) @ *-*-service ---
[INFO] Replacing main artifact with repackaged archive
[INFO] 
[INFO] --- jacoco-maven-plugin:0.8.6:report (default-report) @ *-*-service ---
[INFO] Loading execution data file C:\Users\*\OneDrive\Documents\IntelliJ Projects\*-*-service\*-*-service\target\jacoco.exec
[INFO] Analyzed bundle '*-*-service' with 19 classes
[INFO] 
[INFO] --- jacoco-maven-plugin:0.8.6:check (jacoco-check) @ *-*-service ---
[INFO] Loading execution data file C:\Users\*\OneDrive\Documents\IntelliJ Projects\*-*-service\*-*-service\target\jacoco.exec
[INFO] Analyzed bundle '*-*-service' with 6 classes
[WARNING] Rule violated for class com.*.**.mapper.*Mapper: lines covered ratio is 0.00, but expected minimum is 0.80
[WARNING] Rule violated for class com.*.**.mapper.*Mapper: branches covered ratio is 0.00, but expected minimum is 0.80
[WARNING] Rule violated for class com.*.**.mapper.*Mapper: lines covered ratio is 0.00, but expected minimum is 0.80
[WARNING] Rule violated for class com.*.**.controller.*Controller: lines covered ratio is 0.00, but expected minimum is 0.80
[WARNING] Rule violated for class com.*.**.controller.*Controller: lines covered ratio is 0.00, but expected minimum is 0.80
[WARNING] Rule violated for class com.*.**.service.*Service: lines covered ratio is 0.00, but expected minimum is 0.80
[WARNING] Rule violated for class com.*.**.service.*Service: lines covered ratio is 0.00, but expected minimum is 0.80
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  5.388 s
[INFO] Finished at: 2021-04-11T19:48:54+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.jacoco:jacoco-maven-plugin:0.8.6:check (jacoco-check) on project *-*-service: Coverage checks have not been met. See log for details. -> [Help 1]

I am using IntelliJ-IDEA ultimate version 2021.1 (Latest at post date )我正在使用 IntelliJ-IDEA 终极版 2021.1(最新发布日期)

Any help on getting my tests recognised in a full maven build would be greatly appreciated.任何有关在完整的 maven 构建中识别我的测试的帮助将不胜感激。 Thanks谢谢

Please read the log, and check [ERROR].请阅读日志,并检查 [ERROR]。 You are using JDK 13 and some POM added -Xverify:none and -noverify in the configuration parameter argLine .您正在使用 JDK 13 并且一些 POM 在配置参数argLine中添加了-Xverify:none-noverify

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM