Java Language Unit Testing

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!


Unit testing is an integral part of test-driven development, and an important feature for building any robust application. In Java, Unit testing is almost exclusively performed using external libraries and frameworks, most of which have their own documentation tag. This stub serves as a means of introducing the reader to the tools available, and their respective documentation.


Unit Test Frameworks

There are numerous frameworks available for unit testing within Java. The most popular option by far is JUnit. It is documented under the following:


JUnit4 - Proposed tag for JUnit4 features; not yet implemented.

Other unit test frameworks do exist, and have documentation available:


Unit Testing Tools

There are several other tools used for unit testing:

Mockito - Mocking framework; allows objects to be mimicked. Useful for mimicking the expected behavior of an external unit within a given unit's test, as to not link the external unit's behavior to the given unit's tests.

JBehave - BDD Framework. Allows tests to be linked to user behaviors (allowing requirement/scenario validation). No documents tag available at time of writing; here is an external link.

Got any Java Language Question?