How to run JUnit test cases from the command line

前端 未结 11 1579
花落未央
花落未央 2020-11-22 02:09

I would like to run JUnit test cases from the command line. How can I do this?

11条回答
  •  悲哀的现实
    2020-11-22 02:43

    The answer that @lzap gave is a good solution. However, I would like to add that you should add . to the class path, so that your current directory is not left out, resulting in your own classes to be left out. This has happened to me on some platforms. So an updated version for JUnit 4.x would be:

    java -cp .:/usr/share/java/junit.jar org.junit.runner.JUnitCore [test class name]
    

提交回复
热议问题