JUnit testing

JUnit is a Java framework that supports writing unit tests that help ensure your code works as desired, and existing code is not broken by new changes. It is often useful to create JUnit tests during development to verify that your code works as expected, and to keep and rerun the tests in the future to ensure that later changes in your (or someone else's code) don't unexpectedly break your code.

More information on JUnit testing philosophy is available at JUnit.org.

Note: This document assumes that you use Eclipse. However you can choose to use different IDE but then you have to find how to achieve the equivalent functionality that Eclipse provides.

Assuming you have an existing JUnit test class, you can execute them directly within Eclipse by:

  • Right-clicking on the class in Package Explorer

    Run -> JUnit Test

All the tests for an application can be run from Eclipse by running the com.splwg.AllTests class in the "test" directory as a JUnit test.