1

I have a jar installed in my local ~/.m2 repo and I would like to execute a single test using the -Dtest option via a python script. I tried using this command on the command line mvn surefire:test -DdependenciesToScan=groupId:artifactId -Dtest=NameOfTest, however it doesn't seem like maven is finding the NameOfTest in the groupId:artifactId dependency and returning back with no tests executed? Any way to execute a single test in an already installed maven artifact?

Ian
  • 30,182
  • 19
  • 69
  • 107
Salil Surendran
  • 2,245
  • 4
  • 27
  • 42

1 Answers1

0

Typically Java classes in src/test/java (or your corresponding test sources directory) will not end up in a built artifact by maven by default. If you inspect the contents of the JAR, you will likely notice no compiled test classes, which is why maven can't find them.

If you really want your test source compiled into the JAR, there are plugins to help you. Particularly, the standard Maven JAR Plugin.

However, I would suggest you consider carefully why you need test classes in a built artifact. The standard use of test suites is to test the main source code being built. There are some situations that have been argued where having tests in the final artifact are valid, but they are rare and usually can be worked around in other ways ( Related discussion ).

Community
  • 1
  • 1
alexanderific
  • 780
  • 7
  • 16