From d859f6e0e39805b3b239a724fd03731f82e836a1 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sat, 4 Aug 2018 18:54:00 +0200 Subject: [PATCH] Test Framework: Only show "Unit Tests" node, if there are unit tests --- .../net/sourceforge/pmd/testframework/PMDTestRunner.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pmd-test/src/main/java/net/sourceforge/pmd/testframework/PMDTestRunner.java b/pmd-test/src/main/java/net/sourceforge/pmd/testframework/PMDTestRunner.java index 9b4f12f82a..0f9b6d310f 100644 --- a/pmd-test/src/main/java/net/sourceforge/pmd/testframework/PMDTestRunner.java +++ b/pmd-test/src/main/java/net/sourceforge/pmd/testframework/PMDTestRunner.java @@ -23,13 +23,13 @@ import org.junit.runners.model.InitializationError; * A JUnit Runner, that combines the default {@link JUnit4} * and our custom {@link RuleTestRunner}. * It allows to selectively execute single test cases (it is {@link Filterable}). - * + * *

Note: Since we actually run two runners one after another, the static {@code BeforeClass} * and {@Code AfterClass} methods will be executed twice and the test class will be instantiated twice, too.

* *

In order to use it, you'll need to subclass {@link SimpleAggregatorTst} and * annotate your test class with RunWith:

- * + * *
  * @RunWith(PMDTestRunner.class)
  * public class MyRuleSetTest extends SimpleAggregatorTst {
@@ -78,7 +78,9 @@ public class PMDTestRunner extends Runner implements Filterable, Sortable {
     public Description getDescription() {
         Description description = Description.createSuiteDescription(klass);
         description.addChild(createChildrenDescriptions(ruleTests, "Rule Tests"));
-        description.addChild(createChildrenDescriptions(unitTests, "Unit Tests"));
+        if (ruleTests.hasUnitTests()) {
+            description.addChild(createChildrenDescriptions(unitTests, "Unit Tests"));
+        }
         return description;
     }