I don't usually do Java very much, but I wanted to use JUnit a little, so I made a note of how to use it quickly.
While saying "on Ubuntu", the confirmation environment is "Ubuntu 16.04.3 LTS" of "Bash on Ubuntu on Windows", but I think that the real thing is okay.
sudo apt install junit
javac -cp ./:/usr/share/java/junit.jar TestClassName.java
It's really a good idea to add the jar to the environment variable CLASSPATH.
junit TestClassName
You can run it with java nachara
, which is more convenient.
sudo apt install junit4
javac -cp ./:/usr/share/java/junit4.jar TestClassName.java
You don't have to give the jar a long version name.
java -cp ./:/usr/share/java/junit4.jar org.junit.runner.JUnitCore TestClassName
There seems to be no junit4
command for JUnit 4 a little disappointing ...
If you want to make your own, can you do it right away?
-"JUnit4 memo (Hishidama's JUnit4 Memo)" --Differences between JUnit 3 and JUnit 4 etc.
Recommended Posts