Self-testing code
Appearance
Self-testing code is software which incorporates built-in tests (see test-first development).
In Java, to execute a unit test, a class can have methods like the following.
public static void main(String[] args) { test(); } static void test() { assert foo == bar; }
Executing the class from the command line invokes main
, which runs the test. To invoke a full system test, a class can incorporate a method call.
public static void main(String[] args) { test(); TestSuite.test(); // invokes full system test }