Step 1: Verify Java Installation
Open Terminal check Java version.
You should get an output similar to this.
java version "14.0.2" 2020-07-14Java(TM) SE Runtime Environment (build 14.0.2+12-46) Java HotSpot(TM) 64-Bit Server VM (build 14.0.2+12-46, mixed mode, sharing)
If you do not have Java on your mac, install JDK from https://www.oracle.com/java/technologies/javase-downloads.html
By click on JDK Download and following the Installation Instructions
Step 2: Set JAVA_HOME
Using Finder Go to Folder, go to /Library/Java/JavaVirtualMachines/ and verify that /jdk-XX.XX.XX.jdk/Contents/Home/bin/ folder exist and that there are Unix executables including java and javac. (XX means numbers based on your Java installation.)
(Make sure you replace XX with the actual numbers from what you see in Finder.)
Verify Java install by using
java -version command again.
Restart Terminal and test by entering
Your output should show the path you just set.
Step 3: Download JUnit 4
Go to https://github.com/junit-team/junit4/wiki/Download-and-Install and download junit.jar and hamcrest-core.jar. The file names should be junit-X.XX.X.jar and hamcrest-core-X.X.jar. (XX means numbers.)
Create a folder name JUNIT in your Home using Finder. Move both files from Downloads to JUNIT folder.
Step 4: Setting JUNIT_HOME and CLASSPATH
zsh, so edit your
.zshrc file (It’s a hidden file). Go to your Home folder using Finder. Hold down Cmd + Shift + “.” (That’s the dot). Finder will now show you all the hidden files. Open
.zshrc file with a text editor, paste the following commands and save it.
export JUNIT_HOME="$HOME/JUNIT"export PATH="$PATH:$JUNIT_HOME" export CLASSPATH="$CLASSPATH:$JUNIT_HOME/junit-X.XX.X.jar:$JUNIT_HOME/hamcrest-core-X.X.jar"
(Don’t forget to replace the XXs with numbers.)
Now, restart your Terminal and test the following:
The output should show the path you just set.
The output should show the path you just set for both files.
Step 5: Test JUnit Setup
Follow Step 6 and 7 from https://www.tutorialspoint.com/junit/junit_environment_setup.htm
- TutorialsPoint JUnit – Environment Setup https://www.tutorialspoint.com/junit/junit_environment_setup.htm
- GitHub junit-team junit4 https://github.com/junit-team/junit4/wiki/Download-and-Install
- Coolest Guides On The Planet – How to Add to the Shell Path in macOS Catalina 10.5 using Terminal https://coolestguidesontheplanet.com/how-to-add-to-the-shell-path-in-macos-using-terminal/