Unit testing in Jalview

In June 2015, the Jalview team adopted TestNG for handling unit tests, and all existing JUnit tests were ported to TestNG.

Test Groups

TestNG provides the ability to perform sophisticated grouping of tests using method annotations. This enables TestNG to be invoked and asked to include a certain set of groups (or regular expression) while excluding another set. This gives maximum flexibility in how tests are partitioned and doesn't require you to recompile anything if you want to run two different sets of tests back to back.

The following test groups are available within the Jalview test environment:

Writing new tests

To write a new TestNG tests in Jalview, create a new java class and create test methods which are properly annotated with appropriate TestNG annotations. Here is a simple example test:

    package jalview.test;
    
    import org.testng.annotations.*;
    
    public class SimpleTest {
 
 	 @BeforeClass(alwaysRun = true)
 	 public void setUp() {
	   // code that will be invoked when this test is instantiated
	 }
 
	 @Test(groups = { "Functional" })
	 public void aFunctionalTest() {
	   System.out.println("Functional test");
	 }
 
	 @Test(groups = { "Network" })
	 public void aNetworkDependentTest() {
	    System.out.println("Network dependent test");
	 } 

	 @Test(groups = { "External" })
	 public void anExternalDependencyTest() {
	    System.out.println(“Test with external dependence to a third party resource");
	 } 

	 @Test(groups = { "Interactive" })
	 public void anInteractiveTest() {
	    System.out.println("Human interactive test");
	 }
     }

Test Execution

The TestNG tests for Jalview can be executed in any of the following ways:

TestNG Tutorial

You can find more up-to-date documentations and tutorials on TestNG from the following recommended links:
http://http://testng.org/doc/documentation-main.html
http://www.tutorialspoint.com/testng/