19

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.

greenberet123
  • 1,351
  • 1
  • 12
  • 22
  • Possibly related https://stackoverflow.com/questions/32643420/is-there-a-maven-plugin-listing-all-junit-tests-in-a-multi-module-project – ilooner May 20 '18 at 22:01

1 Answers1

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.

ntg
  • 12,950
  • 7
  • 74
  • 95
  • 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. – Eugene May 13 '23 at 05:21