Stats

94 Contributors: 1 Friday, December 9, 2016
Licensed under: CC-BY-SA
Not affiliated with Stack Overflow
Rip Tutorial: riptutorial@gmail.com
Roadmap: roadmap
Download eBook

Unit Testing

Download java eBook

Introduction

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.

Remarks

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:

JUnit

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

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

TestNG

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.

Related Examples