From aaabd20173ad7add1ea4a7942e17eb4ac2c554d2 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sun, 9 Sep 2018 12:38:25 +0200 Subject: [PATCH] [test] Provide a default implementation for test setUp --- .../pmd/testframework/SimpleAggregatorTst.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pmd-test/src/main/java/net/sourceforge/pmd/testframework/SimpleAggregatorTst.java b/pmd-test/src/main/java/net/sourceforge/pmd/testframework/SimpleAggregatorTst.java index d4187f7f19..4deb872cfb 100644 --- a/pmd-test/src/main/java/net/sourceforge/pmd/testframework/SimpleAggregatorTst.java +++ b/pmd-test/src/main/java/net/sourceforge/pmd/testframework/SimpleAggregatorTst.java @@ -20,13 +20,20 @@ public abstract class SimpleAggregatorTst extends RuleTst { private List rules = new ArrayList<>(); /** - * Configure the rule tests to be executed. Implement this method in - * subclasses by calling adRule. + * Configure the rule tests to be executed. Override this method in + * subclasses by calling addRule. + *

The default implementation will use the package name and test class name, + * to determine the ruleset and rule under test. * * @see #addRule(String, String) */ protected void setUp() { - // empty, to be overridden + String[] packages = getClass().getPackage().getName().split("\\."); + String categoryName = packages[packages.length - 1]; + String language = packages[packages.length - 3]; + String rulesetXml = "category/" + language + "/" + categoryName + ".xml"; + + addRule(rulesetXml, getClass().getSimpleName().replaceFirst("Test$", "")); } /**