I ran the following command to produce a test-jar: mvn jar:test-jar.
What's the mvn command to execute all unit-tests?
When you're creating a jar containing test-classes, you would probably want to reuse those classes. For example, some common test fixtures or abstract base classes, and so on.
In other words, when you run mvn jar:test-jar, you create new artifact, which you can add as dependency in other maven project or module:
<dependencies> <dependency> <groupId>groupId</groupId> <artifactId>artifactId</artifactId> <classifier>tests</classifier> <!-- note the classifier --> <type>test-jar</type> <!-- note the type --> <version>version</version> <scope>test</scope> </dependency> </dependencies> Note: that such approach is not the preferred way, since test-jar will loose transitive test-scoped dependencies
So, returning to the original question: you don't create test-jar to run tests, you create it to reuse test classes between projects or modules (by means of adding dependency).
To run tests you'll simply use standard Maven command:
mvn clean test