Java external libraries
Various statistics include different names in the list of the 20 or 100 most used third-party libraries. In this section, we are going to discuss those of them that are included in most of these lists. All of them are open source projects.
org.junit
JUnit is an open source testing framework that has the root package name org.junit
. It was used throughout this book in several of our code examples. As you could see, it is very easy to set up and use (we have described the steps in Chapter 4, Your First Java Project):
- Add a dependency to the Maven configuration file
pom.xml
- Create a test manually or right-click on the class name you would like to test, select
Go To
, thenTest
, thenCreate New Test
, and then check the methods of the class you would like to test - Write code for the generated test methods with the annotation
@Test
- Add methods with the annotations
@Before
and@After
if necessary
A "unit" is a minimal piece of code that can be tested, thus the name. The best testing...