Migrate remaining tests to JUnit5
This commit is contained in:
@ -191,7 +191,7 @@ class CpdCliTest extends BaseCliTest {
|
||||
* See: https://sourceforge.net/p/pmd/bugs/1178/
|
||||
*/
|
||||
@Test
|
||||
public void testSkipLexicalErrors() throws Exception {
|
||||
void testSkipLexicalErrors() throws Exception {
|
||||
runCli(VIOLATIONS_FOUND,
|
||||
"--minimum-tokens", "10",
|
||||
"-d", BASE_RES_PATH + "badandgood/",
|
||||
@ -205,21 +205,21 @@ class CpdCliTest extends BaseCliTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void jsShouldFindDuplicatesWithDifferentFileExtensions() throws Exception {
|
||||
void jsShouldFindDuplicatesWithDifferentFileExtensions() throws Exception {
|
||||
runCli(VIOLATIONS_FOUND, "--minimum-tokens", "5", "--language", "js",
|
||||
"-d", BASE_RES_PATH + "tsFiles/File1.ts", BASE_RES_PATH + "tsFiles/File2.ts")
|
||||
.checkStdOut(containsString("Found a 9 line (32 tokens) duplication in the following files"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jsShouldFindNoDuplicatesWithDifferentFileExtensions() throws Exception {
|
||||
void jsShouldFindNoDuplicatesWithDifferentFileExtensions() throws Exception {
|
||||
runCli(OK, "--minimum-tokens", "5", "--language", "js",
|
||||
"-d", BASE_RES_PATH + "tsFiles/")
|
||||
.checkStdOut(emptyString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void renderEmptyReportXml() throws Exception {
|
||||
void renderEmptyReportXml() throws Exception {
|
||||
runCli(OK, "--minimum-tokens", "5", "--language", "js",
|
||||
"-f", "xml",
|
||||
"-d", BASE_RES_PATH + "tsFiles/")
|
||||
|
@ -13,7 +13,7 @@ import java.util.List;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
public class ForceLanguageCliTest extends BaseCliTest {
|
||||
class ForceLanguageCliTest extends BaseCliTest {
|
||||
|
||||
private static final String BASE_DIR = "src/test/resources/net/sourceforge/pmd/cli/forceLanguage/";
|
||||
private static final String RULE_MESSAGE = "Violation from ReportAllRootNodes";
|
||||
@ -29,19 +29,19 @@ public class ForceLanguageCliTest extends BaseCliTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void analyzeSingleXmlWithoutForceLanguage() throws Exception {
|
||||
void analyzeSingleXmlWithoutForceLanguage() throws Exception {
|
||||
runCli(OK, "-d", BASE_DIR + "src/file1.ext")
|
||||
.verify(r -> r.checkStdOut(containsStringNTimes(0, RULE_MESSAGE)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void analyzeSingleXmlWithForceLanguage() throws Exception {
|
||||
void analyzeSingleXmlWithForceLanguage() throws Exception {
|
||||
runCli(VIOLATIONS_FOUND, "-d", BASE_DIR + "src/file1.ext", "--force-language", "dummy")
|
||||
.verify(r -> r.checkStdOut(containsStringNTimes(1, RULE_MESSAGE)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void analyzeDirectoryWithForceLanguage() throws Exception {
|
||||
void analyzeDirectoryWithForceLanguage() throws Exception {
|
||||
runCli(VIOLATIONS_FOUND, "-d", BASE_DIR + "src/", "--force-language", "dummy")
|
||||
.verify(r -> r.checkStdOut(containsStringNTimes(3, RULE_MESSAGE)));
|
||||
}
|
||||
|
@ -213,7 +213,7 @@ class RuleSetFactoryTest extends RulesetFactoryTestBase {
|
||||
* @see <a href="https://github.com/pmd/pmd/issues/4279">[java] TestClassWithoutTestCases - can not set test pattern to empty #4279</a>
|
||||
*/
|
||||
@Test
|
||||
public void testEmptyStringProperty() {
|
||||
void testEmptyStringProperty() {
|
||||
Rule r = loadFirstRule("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
||||
+ "<ruleset name=\"test\">\n "
|
||||
+ " <description>ruleset desc</description>\n "
|
||||
|
@ -12,20 +12,20 @@ import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import net.sourceforge.pmd.PMDConfiguration;
|
||||
import net.sourceforge.pmd.PmdAnalysis;
|
||||
import net.sourceforge.pmd.lang.document.TextFile;
|
||||
import net.sourceforge.pmd.util.IOUtil;
|
||||
|
||||
public class ZipFileTest {
|
||||
class ZipFileTest {
|
||||
|
||||
private static final String ZIP_PATH = "src/test/resources/net/sourceforge/pmd/cli/zipWithSources.zip";
|
||||
private final Path zipPath = Paths.get(ZIP_PATH);
|
||||
|
||||
@Test
|
||||
public void testZipFile() {
|
||||
void testZipFile() {
|
||||
PMDConfiguration conf = new PMDConfiguration();
|
||||
conf.addInputPath(zipPath);
|
||||
// no relativizeRoot paths configured -> we use the relative path
|
||||
@ -40,7 +40,7 @@ public class ZipFileTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testZipFileRelativizeWith() {
|
||||
void testZipFileRelativizeWith() {
|
||||
PMDConfiguration conf = new PMDConfiguration();
|
||||
conf.addInputPath(zipPath);
|
||||
conf.addRelativizeRoot(Paths.get("src/test/resources"));
|
||||
@ -55,7 +55,7 @@ public class ZipFileTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testZipFileRelativizeWithRoot() {
|
||||
void testZipFileRelativizeWithRoot() {
|
||||
PMDConfiguration conf = new PMDConfiguration();
|
||||
conf.addInputPath(zipPath);
|
||||
// this configures "/" as the relativizeRoot -> result are absolute paths
|
||||
|
@ -4,8 +4,8 @@
|
||||
|
||||
package net.sourceforge.pmd.cpd;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
@ -14,14 +14,14 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import net.sourceforge.pmd.util.Predicate;
|
||||
|
||||
public class CPDReportTest {
|
||||
class CPDReportTest {
|
||||
|
||||
@Test
|
||||
public void testFilterMatches() {
|
||||
void testFilterMatches() {
|
||||
List<Match> originalMatches = Arrays.asList(
|
||||
createMatch("file1.java", "file2.java", 1),
|
||||
createMatch("file1.java", "file3.java", 2),
|
||||
|
Reference in New Issue
Block a user