Introduction to JUnit

The JUnit package contains a simple, open source framework to write and run repeatable tests. It is an instance of the xUnit architecture for unit testing frameworks. JUnit features include assertions for testing expected results, test fixtures for sharing common test data, and test runners for running tests.

This package is known to build and work properly using an LFS-8.2 platform.

Package Information

JUnit Dependencies


Apache-Maven-3.5.3 and UnZip-6.0

User Notes: http://wiki.linuxfromscratch.org/blfs/wiki/junit

Installation of JUnit

First remove a test, which fails with Java 9.

sed -e '/MethodsSorted/i    @Ignore' \
    -i src/test/java/org/junit/runners/model/TestClassTest.java

Install Junit by running the following commands:

mvn -DjdkVersion=1.6 install

The tests are run as part of the command above.

If you wish to generate the documentation, issue:

mvn site

Install the files in the final location as the root user:

install -v -m755 -d             /usr/share/java/junit-4.12 &&
cp -v target/junit-4.12.jar     /usr/share/java/junit-4.12 &&
cp -v lib/hamcrest-core-1.3.jar /usr/share/java/junit-4.12

if the documentation was built, install it as the root user:

install -v -m755 -d    /usr/share/doc/junit-4.12 &&
cp -v -R target/site/* /usr/share/doc/junit-4.12

If you have followed the instructions in Configuring the JAVA environment, there is nothing more to do: the CLASSPATH variable would be automatically updated.


Installed Programs: None
Installed Libraries: hamcrest-core and junit jar files
Installed Directories: /usr/share/doc/junit-4.12 and /usr/share/java/junit-4.12

Short Descriptions


contains java classes to support the xUnit framework testing architecture.


contains java classes to support matchers used in xUnit tests.

Last updated on 2018-03-19 16:22:16 -0500