From: Jim Procter Date: Mon, 22 Aug 2016 10:53:13 +0000 (+0100) Subject: JAL-2154 tidy assert messages and fix test to verify asserts were raised when expected X-Git-Tag: Release_2_10_0~47^2~4^2~43^2~26 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=f11011db0fddcb60941d20e4ee9d63a87fda2a23;p=jalview.git JAL-2154 tidy assert messages and fix test to verify asserts were raised when expected --- diff --git a/test/jalview/datamodel/AlignmentTest.java b/test/jalview/datamodel/AlignmentTest.java index 915d860..dbecc20 100644 --- a/test/jalview/datamodel/AlignmentTest.java +++ b/test/jalview/datamodel/AlignmentTest.java @@ -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); } }