1
2
3
4
5 package com.qulice.pmd;
6
7 import com.qulice.spi.Environment;
8 import com.qulice.spi.Violation;
9 import java.io.File;
10 import java.util.Collections;
11 import org.hamcrest.MatcherAssert;
12 import org.hamcrest.Matchers;
13 import org.junit.jupiter.api.Test;
14
15
16
17
18
19
20
21 final class PmdExclusionTest {
22
23 @Test
24 void skipsAnalysisWhenAllFilesExcluded() throws Exception {
25 final String file = "src/main/java/Main.java";
26 final Environment env = new ExcludingEnvironment(
27 new Environment.Mock()
28 .withFile(file, "class Main { int x = 0; }")
29 );
30 MatcherAssert.assertThat(
31 "Excluded files must not yield violations",
32 new PmdValidator(env).validate(
33 Collections.singletonList(new File(env.basedir(), file))
34 ),
35 Matchers.<Violation>empty()
36 );
37 }
38 }