I have wrote a piece of code in Junit. I need to run it without eclipse. Any suggestions how can I do that ?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Since Eclipse 2018-09 in Java Application and JUnit launch configurations there is a button Show Command Line for that.
See also: video that shows this feature in action
回答2:
Yes, you have an option to run your test cases in command line,
Example:
As you are running the mvn clean install for building your application, In the same way, you can also run your test cases as well by using the command.
1. Command to compile your test class >> **javac -cp junit-4.12.jar;. UserDAOTest.java ProductDAOTest.java** --> general command is >> **javac -cp <junit-jar-file>;. TestClass1.java TestClass2.java**
2. Run the test cases >> ** java -cp <junit-jar>;<hamcrest-jar>;. org.junit.runner.JUnitCore TestClass1 TestClass2 **
3. Running the unit test cases by Maven Command Line >> mvn test >> mvn clean test >> mvn clean compile test