Minimal testing framework for Java
javac Program.java
java -ea Program
It should print "All tests are passed!"
Create a test class that inherits JMinitest
public class LinkedListTest extends JMinitest
public void test_the_truth() {
verify(1).toEqual(1);
}
}
All public methods start with test_
will be invoked upon calling new LinkedListTest().runTests();
.
Currently JMinitest supports only toEqual
and toBeNull
assertions. Yet adding new assertion is as easy as adding new method in Verifiable
class.
public class Verifiable<T> {
// ...
public void toBeTrue() {
assert subject == true : "Expected true but was false";
}
}
- Do not halt the test runner on the first assertion failure and continue to run all the test cases.
- Show test runner statistics such as
total_tests
,passed_tests
,failed_tests
and testrunning_time
. - Run particular test class or test case in a class.