From f11011db0fddcb60941d20e4ee9d63a87fda2a23 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Mon, 22 Aug 2016 11:53:13 +0100 Subject: [PATCH] JAL-2154 tidy assert messages and fix test to verify asserts were raised when expected --- test/jalview/datamodel/AlignmentTest.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) 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); } } -- 1.7.10.2