From ee020670b6114c0691e3f9ea642b785e60a33632 Mon Sep 17 00:00:00 2001 From: Xavier Le Vourch Date: Wed, 24 Oct 2007 18:19:19 +0000 Subject: [PATCH] junit assert failures should not be converted into errors AssertionError was caught by Throwable and rethrown as RuntimeException git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@5575 51baf565-9d33-0410-a72c-fc3788e3496d --- .../pmd/testframework/RuleTst.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/pmd/regress/test/net/sourceforge/pmd/testframework/RuleTst.java b/pmd/regress/test/net/sourceforge/pmd/testframework/RuleTst.java index 577d7389e2..276e0c1435 100644 --- a/pmd/regress/test/net/sourceforge/pmd/testframework/RuleTst.java +++ b/pmd/regress/test/net/sourceforge/pmd/testframework/RuleTst.java @@ -72,17 +72,20 @@ public abstract class RuleTst { Properties ruleProperties = rule.getProperties(); Properties oldProperties = (Properties)ruleProperties.clone(); try { - if (test.getProperties() != null) { - oldProperties = (Properties)ruleProperties.clone(); - ruleProperties.putAll(test.getProperties()); + int res; + try { + if (test.getProperties() != null) { + oldProperties = (Properties)ruleProperties.clone(); + ruleProperties.putAll(test.getProperties()); + } + + res = processUsingStringReader(test.getCode(), rule, test.getSourceType()).size(); + } catch (Throwable t) { + t.printStackTrace(); + throw new RuntimeException("Test \"" + test.getDescription() + "\" on Rule \"" + test.getRule().getName() + "\"failed"); } - - int res = processUsingStringReader(test.getCode(), rule, test.getSourceType()).size(); assertEquals("\"" + test.getDescription() + "\" test resulted in wrong number of failures,", - test.getNumberOfProblemsExpected(), res); - } catch (Throwable t) { - t.printStackTrace(); - throw new RuntimeException("Test \"" + test.getDescription() + "\" on Rule \"" + test.getRule().getName() + "\"failed"); + test.getNumberOfProblemsExpected(), res); } finally { //Restore old properties ruleProperties.clear();