How to Install JUnit Libraries on Linux? - GeeksforGeeks

22 Sep, 2021
JUnit is basically a unit testing framework for Java. JAVA provides a JUnit framework for unit testing, unit testing is simply a process by which we ensure that the code works the way it was intended to, i.e. we check individual units of source code, such as functions, methods, and class.  And normally we just test everything that could reasonably break. The JUnit helps us to run and write repeatable automated tests. The latest version of JUnit is JUnit 5
Follow the below steps to install JUnit libraries using the apt install command:
 Step 1: Open up the terminal and run the following command to update your current system.
sudo apt update
sudo apt upgrade
Step 2: Now we are going to install a package manager called “aptitude”. After that, run the following command to install JUnit.
sudo apt install aptitude
Step 3: After installing aptitude run the following command to install JUnit.
sudo aptitude install junit
To remove JUnit run the following command:
sudo aptitude remove junit
Note: If above method doesn’t work for your system you can try the method  2.
To download the JUnit follow the below steps:
Step 1: Open up the terminal and run the following command to download the JUnit.zip.
wget https://sourceforge.net/projects/junit/files/junit/4.10/junit4.10.zip
downloading junit.zip
Step 2: Move this junit file to another folder called JUnit and unzipping the file.
 Making directory for JUnit using the below command:
mkdir JUnit
Move junit4.10.zip to the new folder, JUnit with the below command:
mv junit4.10.zip /home/amninder/Downloads/JUnit/
Unzip the file using the below command:
unzip junit4.10.zip
Now, make sure you are in Download/JUnit folder.
 Step 3:  Navigate to the junit folder and copy the junit-4.10.jar path to the environment variable by running the following commands:
export JUNIT_HOME=/home/amninder/Downloads/JUnit/junit4.10
Step 4: Set the JUnit class path and export the new JUnit-4.10.jar path to the environment variable by running the following commands:
Command 1:
export CLASSPATH=$JUNIT_HOME/junit-4.10.jar
Here, $JUNIT_HOME indicates that we are accessing the value of JUNIT_HOME from the previous step 3.
Command 2:
export CLASSPATH=/home/amninder/Downloads/JUnit/junit4.10/junit-4.10.jar
Both the above commands from step 3 are serving the same purpose. We can use any of them, but not both.
At this point, the JUnit is successfully installed.
 To check if the JUnit is correctly installed run the following command:
java org.junit.runner.JUnitCore junit.tests.AllTests
Note: To uninstall JUnit simply delete the folder where you have pasted the JUnit jar file and it will remove the JUnit from the system.
Blogathon-2021
how-to-install
Picked
Blogathon
How To
Installation Guide
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Import JSON Data into SQL Server?
How to Create a Table With Multiple Foreign Keys in SQL?
How to Install Tkinter in Windows?
SQL Query to Convert Datetime to Date
SQL Query to Create Table With a Primary Key
How to Install PIP on Windows ?
How to Find the Wi-Fi Password Using CMD in Windows?
How to Align Text in HTML?
How to install Jupyter Notebook on Windows?
How to Install OpenCV for Python on Windows?