From 00a240a09c1a144a328338ff5bf54381e6203d6f Mon Sep 17 00:00:00 2001 From: tcofoegbu Date: Wed, 2 Sep 2015 13:14:00 +0100 Subject: [PATCH] JAL-1805 JAL-1782 added a draft documentation for TestNG to jalview doc directory --- doc/UnitTesting.html | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 doc/UnitTesting.html diff --git a/doc/UnitTesting.html b/doc/UnitTesting.html new file mode 100644 index 0000000..7b43de3 --- /dev/null +++ b/doc/UnitTesting.html @@ -0,0 +1,111 @@ + + + +Unit testing in Jalview + + +

Unit testing in Jalview

+ +

+In June 2015, the Jalview team adopted TestNG as the favourite unit testing framework. Consequently 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/ + + + + + -- 1.7.10.2