JAL-1782 refactored JAL-1766 JAL-653 tests to TestNG
authorJim Procter <jprocter@issues.jalview.org>
Wed, 24 Jun 2015 13:26:01 +0000 (14:26 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Wed, 24 Jun 2015 13:26:01 +0000 (14:26 +0100)
test/jalview/datamodel/SequenceDummyTest.java
test/jalview/ext/htsjdk/TestHtsContigDb.java
test/jalview/io/AnnotatedPDBFileInputTest.java
test/jalview/io/Gff3tests.java
test/jalview/io/HtmlFileTest.java
test/jalview/ws/jabaws/JalviewJabawsTestUtils.java

index 2fc1934..ca1ac7d 100644 (file)
@@ -1,15 +1,15 @@
 package jalview.datamodel;
 
+import org.testng.Assert;
+import org.testng.annotations.Test;
 
-import org.junit.Assert;
-import org.junit.Test;
 
+@Test
 public class SequenceDummyTest
 {
   /**
    * test for become method
    */
-  @Test
   public void testBecome()
   {
     SequenceI seq = new Sequence("OrigSeq", "ASEQUENCE");
@@ -19,10 +19,12 @@ public class SequenceDummyTest
     SequenceDummy dummySeq = new SequenceDummy("OrigSeq");
     dummySeq.addSequenceFeature(ofeat);
     dummySeq.become(seq);
-    Assert.assertFalse("Dummy sequence did not become a full sequence",
-            dummySeq.isDummy());
-    Assert.assertTrue("Sequence was not updated from template", seq
-            .getSequenceAsString().equals(dummySeq.getSequenceAsString()));
+    Assert.assertFalse(dummySeq.isDummy(),
+            "Dummy sequence did not become a full sequence");
+    Assert.assertTrue(
+            seq.getSequenceAsString()
+                    .equals(dummySeq.getSequenceAsString()),
+            "Sequence was not updated from template");
     boolean found = false;
     for (SequenceFeature sf : dummySeq.getSequenceFeatures())
     {
@@ -32,7 +34,7 @@ public class SequenceDummyTest
         break;
       }
     }
-    Assert.assertTrue("Didn't retain original sequence feature", found);
+    Assert.assertTrue(found, "Didn't retain original sequence feature");
 
     // todo - should test all aspect of copy constructor
   }
index d168c27..5e0f99a 100644 (file)
@@ -7,8 +7,8 @@ import jalview.datamodel.SequenceI;
 
 import java.io.File;
 
-import org.junit.Assert;
-import org.junit.Test;
+import org.testng.Assert;
+import org.testng.annotations.Test;
 
 /**
  * @author jprocter
index 1c6a489..c40df35 100644 (file)
@@ -17,7 +17,7 @@ import jalview.structure.StructureSelectionManager;
 
 import java.io.File;
 
-import org.junit.Assert;
+import org.testng.Assert;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.BeforeMethod;
@@ -61,8 +61,8 @@ public class AnnotatedPDBFileInputTest
       for (int q = p + 1; q < avec.length; q++)
       {
         Assert.assertNotEquals(
-                "Found a duplicate annotation row " + avec[p].label,
-                avec[p], avec[q]);
+avec[p], avec[q],
+                "Found a duplicate annotation row " + avec[p].label);
       }
     }
   }
index 8df44df..56b57af 100644 (file)
@@ -8,8 +8,8 @@ import jalview.gui.AlignFrame;
 
 import java.io.IOException;
 
-import org.junit.Assert;
-import org.junit.Test;
+import org.testng.Assert;
+import org.testng.annotations.Test;
 
 public class Gff3tests
 {
@@ -29,14 +29,15 @@ public class Gff3tests
     AlignFrame af = loader.LoadFileWaitTillLoaded(exonerateSeqs,
             FormatAdapter.FILE);
 
-    Assert.assertEquals("Unexpected number of DNA protein associations", 0,
-            af.getViewport().getAlignment().getCodonFrames().size());
+    Assert.assertEquals(0, af.getViewport().getAlignment().getCodonFrames()
+            .size(), "Unexpected number of DNA protein associations");
 
     af.loadJalviewDataFile(exonerateOutput, FormatAdapter.FILE, null, null);
 
-    Assert.assertNotEquals("Expected at least one DNA protein association",
+    Assert.assertNotEquals(
             0, af.getViewport().getAlignment().getDataset()
-                    .getCodonFrames().size());
+            .getCodonFrames().size(),
+            "Expected at least one DNA protein association");
 
   }
 
@@ -57,7 +58,7 @@ public class Gff3tests
             FormatAdapter.FILE);
 
     boolean parseResult = ffile.parse(dataset, null, null, false, false);
-    Assert.assertTrue("return result should be true", parseResult);
+    Assert.assertTrue(parseResult, "return result should be true");
     checkDatasetfromSimpleGff3(dataset);
   }
 
@@ -66,9 +67,8 @@ public class Gff3tests
   {
     AlignFrame af = new FileLoader(false).LoadFileWaitTillLoaded(
             simpleGff3file, FormatAdapter.FILE);
-    Assert.assertTrue(
-            "Didn't read the alignment into an alignframe from Gff3 File",
-            af != null);
+    Assert.assertTrue(af != null,
+            "Didn't read the alignment into an alignframe from Gff3 File");
     checkDatasetfromSimpleGff3(af.getViewport().getAlignment().getDataset());
   }
 
@@ -81,8 +81,8 @@ public class Gff3tests
             FormatAdapter.FILE);
 
     boolean parseResult = ffile.parse(dataset, null, null, false, true);
-    Assert.assertTrue("return result (relaxedID matching) should be true",
-            parseResult);
+    Assert.assertTrue(parseResult,
+            "return result (relaxedID matching) should be true");
     checkDatasetfromSimpleGff3(dataset);
   }
 
@@ -98,38 +98,41 @@ public class Gff3tests
 
   private void checkDatasetfromSimpleGff3(AlignmentI dataset)
   {
-    Assert.assertEquals("no sequences extracted from GFF3 file", 2,
-            dataset.getHeight());
+    Assert.assertEquals(2, dataset.getHeight(),
+            "no sequences extracted from GFF3 file");
 
     SequenceI seq1 = dataset.findName("seq1"), seq2 = dataset
             .findName("seq2");
     Assert.assertNotNull(seq1);
     Assert.assertNotNull(seq2);
     Assert.assertFalse(
-            "Failed to replace dummy seq1 with real sequence",
             seq1 instanceof SequenceDummy
-                    && ((SequenceDummy) seq1).isDummy());
+            && ((SequenceDummy) seq1).isDummy(),
+            "Failed to replace dummy seq1 with real sequence");
     Assert.assertFalse(
-            "Failed to replace dummy seq2 with real sequence",
             seq2 instanceof SequenceDummy
-                    && ((SequenceDummy) seq2).isDummy());
+            && ((SequenceDummy) seq2).isDummy(),
+            "Failed to replace dummy seq2 with real sequence");
     String placeholderseq = new SequenceDummy("foo").getSequenceAsString();
-    Assert.assertFalse("dummy replacement buggy for seq1",
-            placeholderseq.equals(seq1.getSequenceAsString()));
+    Assert.assertFalse(placeholderseq.equals(seq1.getSequenceAsString()),
+            "dummy replacement buggy for seq1");
     Assert.assertNotEquals("dummy replacement buggy for seq2",
             placeholderseq.equals(seq2.getSequenceAsString()));
-    Assert.assertNotNull("No features added to seq1",
-            seq1.getSequenceFeatures());// != null);
-    Assert.assertEquals("Wrong number of features", 3,
-            seq1.getSequenceFeatures().length);
+    Assert.assertNotNull(seq1.getSequenceFeatures(),
+            "No features added to seq1");
+    Assert.assertEquals(seq1.getSequenceFeatures().length, 3,
+            "Wrong number of features");
     Assert.assertNull(seq2.getSequenceFeatures());
-    Assert.assertEquals("Wrong number of features", 0, seq2
+    Assert.assertEquals(
+            seq2
             .getSequenceFeatures() == null ? 0
-            : seq2.getSequenceFeatures().length);
+ : seq2
+                    .getSequenceFeatures().length, 0,
+            "Wrong number of features");
     Assert.assertTrue(
-            "Expected at least one CDNA/Protein mapping for seq1",
             dataset.getCodonFrame(seq1) != null
-                    && dataset.getCodonFrame(seq1).size() > 0);
+            && dataset.getCodonFrame(seq1).size() > 0,
+            "Expected at least one CDNA/Protein mapping for seq1");
 
   }
   // @Test
index eca3984..09b8990 100644 (file)
@@ -1,7 +1,5 @@
 package jalview.io;
 
-import static org.junit.Assert.fail;
-
 import org.testng.annotations.Test;
 
 public class HtmlFileTest
@@ -10,7 +8,7 @@ public class HtmlFileTest
   @Test(enabled = false)
   public void test()
   {
-    fail("Not yet implemented");
+    org.testng.AssertJUnit.fail("Not yet implemented");
   }
 
 }
index ec901da..91e9244 100644 (file)
  */
 package jalview.ws.jabaws;
 
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
 import jalview.ws.jws2.Jws2Discoverer;
 
 import java.util.Vector;
 
+import org.testng.Assert;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
@@ -54,7 +52,7 @@ public class JalviewJabawsTestUtils
   @Test(enabled = false)
   public void testAnnotExport()
   {
-    fail("Not yet implemented");
+    Assert.fail("Not yet implemented");
   }
 
   public static jalview.ws.jws2.Jws2Discoverer getJabawsDiscoverer()
@@ -84,10 +82,11 @@ public class JalviewJabawsTestUtils
     } catch (Exception e)
     {
       e.printStackTrace();
-      fail("Aborting. Problem discovering services. Tried " + svcurls);
+      Assert.fail("Aborting. Problem discovering services. Tried "
+              + svcurls);
     }
-    assertTrue("Failed to discover any services at ", disc.getServices()
-            .size() > 0);
+    Assert.assertTrue(disc.getServices().size() > 0,
+            "Failed to discover any services at ");
     return disc;
   }