Tutorial
@Testable, @Group, @ExpectableExceptions

@Testable is used to annotate methods to test. @Testable has different attributes (like numberOfInvocations) that you can set. A method can depend on one or more methods.
@Group is used to specify that a method belongs to a group other than "Default Group". A group can depend on one or more groups.
@ExpectableExceptions is used to mark a method as successful if the defined exception is thrown.


public class BasicTest { @Testable public void m1() throws InterruptedException { Thread.sleep(200); } @Testable(dependsOn = {"m1"}) @Group(names = {"GroupA"}) public void m2() { } @Testable @Group(names = {"GroupB", "GroupC"}, dependsOn = {"GroupA"}) @ExpectableExceptions(classes = {AssertionError.class}) public void m3() { assert 1 == 2; } @Testable public void m4() { assert 1 == 2; } @Testable @ExpectableExceptions(classes = {NullPointerException.class}) public void shouldThrowNPE() { Integer i = null; i.byteValue(); } @Testable public void shouldThrowException() { Integer i = new Integer("abc"); i.hashCode(); } @Testable(numberOfInvocations = 10) @Group(names = {"Hacker"}) public void denialOfServiceAttack() throws InterruptedException { Thread.sleep((long)(200. * Math.random())); } @Testable(numberOfInvocations = 10) @Group(names = {"Hacker"}) public void denialOfServiceAttack2() throws InterruptedException { long sleepTime = (long)(200. * Math.random()); if (sleepTime < 50) sleepTime = -1; Thread.sleep(sleepTime); } }
@Configuration

@Configuration can be used to set the parallel mode, the number of threads as well as a custom class for nodes sorting. (DFS.class is used by default)


@Configuration(parallel = true, numberOfThreads = 10, nodesGraphProcessor = DFS.class) public class ParallelTest { @Testable(timeOut = 100) public void test1() throws InterruptedException { Thread.sleep(200); } @Testable(timeOut = 200) @ExpectableExceptions(classes = {InterruptedException.class}) public void test2() throws InterruptedException { Thread.sleep(400); } @Testable(numberOfInvocations = 10, timeOut = 300) public void test3() throws InterruptedException { Thread.sleep(200); } @Testable(timeOut = 400) public void test4() throws InterruptedException { Thread.sleep(400); } @Testable(timeOut = 500) public void test5() throws InterruptedException { Thread.sleep(400); assert 400 == 500; } }
ANT task

A simple ANT task.


<project name="Testinium Build ANT Test" default="testinium-test" basedir=".."> <typedef name="testinium" classname="org.testinium.ant.TestiniumTask"/> <target name="testinium-test" description="--> testing the Testinium target"> <testinium> <path> <pathelement path="/Users/thierryjanaudy/Projects/TESTINIUM/samples/bin"/> </path> <clazz name="org.testinium.samples.BasicTest"/> <clazz name="org.testinium.samples.SimpleTest"/> </testinium> </target> </project>