-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3939 from adangel:improved-rule-test-support
[test] Print Test Method Name for failed rule tests #3939
- Loading branch information
Showing
5 changed files
with
48 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
pmd-test/src/test/java/net/sourceforge/pmd/testframework/TestDescriptorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html | ||
*/ | ||
|
||
package net.sourceforge.pmd.testframework; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import net.sourceforge.pmd.lang.rule.MockRule; | ||
|
||
public class TestDescriptorTest { | ||
@Test | ||
public void testMethodName() { | ||
Assert.assertEquals("MockRule_1_Name", create("Name")); | ||
Assert.assertEquals("MockRule_1_Tests_xyz", create("Tests xyz")); | ||
Assert.assertEquals("MockRule_1_Tests_xyz__false_positive_", create("Tests xyz (false positive)")); | ||
Assert.assertEquals("MockRule_1_Tests_xyz__123", create("Tests xyz #123")); | ||
} | ||
|
||
private String create(String description) { | ||
TestDescriptor descriptor = new TestDescriptor("foo", description, 0, | ||
new MockRule("MockRule", "desc", "msg", "ruleset")); | ||
descriptor.setNumberInDocument(1); | ||
return descriptor.getTestMethodName(); | ||
} | ||
} |