How to Install JUnit Libraries on Linux?
Last Updated :
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
Install JUnit libraries in Linux:
Method 1: Using apt install command
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.
Method 2: By Downloading JUnit zip file
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:
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.
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.
Similar Reads
How to Install JUnit Libraries in MacOS?
JUnit, an essential testing framework for Java developers, simplifies the process of conducting unit tests and ensuring the reliability of your codebase. This guide provides a step-by-step walkthrough of installing JUnit libraries on MacOS, catering to different installation methods. In this guide,
2 min read
How to Install Keras on Linux?
Keras is an open-source software library that offers a Python interface for ANN (artificial neural networks). It acts as an interface for the TensorFlow library. It offers consistent & simple APIs, minimizes the number of user actions required for common use cases, and provides clear & actio
2 min read
How to Install Kotlin on Linux?
Kotlin is a programming language introduced by JetBrains in 2011, the official designer of the most intelligent Java IDE, named Intellij IDEA. This is a strongly statically typed general-purpose programming language that runs on JVM. In 2017, Kotlin is sponsored by Google, announced as one of the of
2 min read
How to Install Java Libraries?
Java Library is the collection of classes that are written by some other programmers that we can use in our code by downloading those classes. Java library allows you to read and modify bytecode generated by an application. Some of the popular bytecode libraries in the Java world are "javassist" and
2 min read
How to Install Lightgbm on Linux?
Lightgbm is an acronym for Light Gradient Boosting Machine. It is a machine learning framework based on decision tree algorithms. It is an open-source and free distributed gradient boosted model library. It is used for classification and other machine learning tasks. It is built by Microsoft Corpora
2 min read
How to Install Boost Library in C++ on Linux?
Boost is a set of libraries for the C++ programming language. It contains 164 individual libraries. It was initially released on September 1, 1999. Furthermore, it provides support for many tasks such as pseudo-random number generation, linear algebra, multithreading, image processing, regular expre
2 min read
How to Install Python-MIDI Library on Linux?
The MIDI library in Python is used to manipulate MIDI data. This library or package is cross-platformed as it can work with various operating systems like Windows, Linux, macOS. So, in this article, we will be installing the MIDI package in Python3 on Linux operating system. Features MIDI is a High-
2 min read
How to Install Java JDK9 on Linux?
As we all know Java is widely used in tech industries, with around 4 billion devices currently using java. This Java installation is going to be very easy and beginner-friendly. In this article, we are going to see a step-by-step guide on how you can install java on your Linux machine. Step-By-Step
4 min read
How to Install Scikit-Learn on Linux?
In this article, we are going to see how to install Scikit-Learn on Linux. Scikit-Learn is a python open source library for predictive data analysis. It is built on NumPy, SciPy, and matplotlib. It is written in Python, Cython, C, and C++ language. It is available for Linux, Unix, Windows, and Mac.
2 min read
How to Install Apache JMeter on Linux?
Apache JMeter is an open-source tool designed for load testing and performance measurement. Itâs widely used by developers and testers for analyzing and measuring the performance of web applications. Here, we will learn the process of installing Apache JMeter on Ubuntu, a popular Linux distribution
3 min read