There are a bunch of questions related to the issue that mvn test doesn't execute test classes where the answer is always, that maven-surefire looks for certain prefixes or postfixes of filenames. I already considered this and it didn't help me as my filenames where already valid.
When I execute mvn test
, the log contains the following section:
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ compiler --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 5 source files to /project_path/target/test-classes
... so mvn test
does actually find my test cases, and indeed, I can find all the compiled test classes in the directory /project_path/target/test-classes/
But still, only one of these 5 test files is actually executed and its tests are run whereas the other 4 are ignored by mvn test
.
Any ideas why that could be the case? I am not really sure which additional information could be helpful to answer this question. Just ping me if there is something that I need to add to the question.
I just found a way to fix it..
Honestly, I don't understand why this makes the difference, but I have used @Test
annotations on my test cases from org.junit.jupiter.api.Test
in the file that was executed correctly by mvn test
and used @Test
annotations from org.junit.Test
in the other files (which were not executed).
I've changed all files to import the @Test
annotation from the jupiter package and then all tests were recognized.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.