Maven - Get list of all tests without running them?
Asked Answered
T

1

21

I have a maven project and I would like to get a list of all the test classes and their file paths, without having to execute all the tests.

After I run "mvn test", the only files that I have under target/ are

checkstyle-cachefile  checkstyle-checker.xml  checkstyle-result.xml  maven-shared-archive-resources

I want something very general, that doesn't require me to edit the pom.xml file.

Tyro answered 18/5, 2018 at 18:9 Comment(1)
Possibly related #32643920Illyria
P
9

In my case, the test classes names were stored in

target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst

You can run mvn test-compile to create it without running the tests.

Policewoman answered 27/5, 2021 at 8:54 Comment(2)
while this is correct, it does a bad job for some cases. it included classes that are not tests (some set-up that you might have in src/test/java), it included abstract classes (that of course are not tests) and are implemented by tests, it incorrectly parses nested classes. Overall, for a CI/CD pipeline, this is un-usable and parsing has to be done by hand.Tinytinya
In addition, it includes real tests that would not have ranCabrales

© 2022 - 2024 — McMap. All rights reserved.