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.3 platform.

Package Information

Additional Downloads

JUnit Dependencies


Apache-Maven-3.5.4 and UnZip-6.0

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

Installation of JUnit

First remove a test, which fails with Java 10.

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

Replace deprecated SecurityManager code:

patch -Np1 -i ../junit4-r4.12-simplify_NoExitSecurityManager-1.patch

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-08-27 21:20:16 -0700