JAL-2154 tidy assert messages and fix test to verify asserts were raised when expected
authorJim Procter <jprocter@issues.jalview.org>
Mon, 22 Aug 2016 10:53:13 +0000 (11:53 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Mon, 22 Aug 2016 10:53:13 +0000 (11:53 +0100)
test/jalview/datamodel/AlignmentTest.java

index 915d860..dbecc20 100644 (file)
@@ -296,23 +296,28 @@ public class AlignmentTest
       }
       // also check validation passes with asserts disabled
       Assert.assertTrue(verifyAlignmentDatasetRefs(al, false, null),
-              "Valid test alignment failed when raiseAsserts disabled:"
+              "Valid test alignment tested false when raiseAsserts disabled:"
                       + msg);
     }
     else
     {
+      boolean assertRaised = false;
       try
       {
-        Assert.assertFalse(verifyAlignmentDatasetRefs(al, true, null));
-        Assert.fail("Invalid test alignment passed but no assertion raised when raiseAsserts enabled:"
-                + msg);
+        verifyAlignmentDatasetRefs(al, true, null);
       } catch (AssertionError ae)
       {
         // expected behaviour
+        assertRaised = true;
+      }
+      if (!assertRaised)
+      {
+        Assert.fail("Invalid test alignment passed when raiseAsserts enabled:"
+                + msg);
       }
       // also check validation passes with asserts disabled
       Assert.assertFalse(verifyAlignmentDatasetRefs(al, false, null),
-              "Invalid test alignment passed when raiseAsserts disabled:"
+              "Invalid test alignment tested true when raiseAsserts disabled:"
                       + msg);
     }
   }