0

I have created a maven project, and inside src/test/java folder, I've created test classes. I want to add test classes into my jar file (using maven), and after this, I want to run one of these test classes from command line (using the generated jar file).

Thank you in advance.

Magicprog.fr
  • 4,072
  • 4
  • 26
  • 35
Mac
  • 99
  • 1
  • 3
  • 13
  • Why do you want your test classes included in your jar? As a kind of self-test? – sisyphus Mar 17 '16 at 11:40
  • Yes, that's what I want, run my test classes from the jar, and this same jar I can run it (run the main class) – Mac Mar 17 '16 at 11:43
  • You know that the tests will run by default if you do `mvn clean package` which is the basic idea of unit tests? By default the test classes or in other words the folder `src/test` will never be part of the packaged jar file... – khmarbaise Mar 17 '16 at 12:02
  • 1
    check [this answer](http://stackoverflow.com/a/36047816/5606016) for exactly the same use case, I provided a solution today – A_Di-Matteo Mar 17 '16 at 12:05
  • Thank you sisyphus, khmarbaise, and A. Di Matteo for your answers! – Mac Mar 17 '16 at 15:30
  • # A. Di Matteo, I used your answer, it works pretty fine :) – Mac Mar 17 '16 at 15:30
  • Sorry, but in this case the use of Asserts is not useful, we have to create simple classes in this case! – Mac Mar 17 '16 at 16:05
  • @Mac you can still use Asserts, check my answer, I updated it – A_Di-Matteo Mar 17 '16 at 20:53

0 Answers0