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
22 final class PmdExclusionTest {
23
24 @Test
25 void skipsAnalysisWhenAllFilesExcluded() throws Exception {
26 final String file = "src/main/java/Main.java";
27 final Environment env = new ExcludingEnvironment(
28 new Environment.Mock()
29 .withFile(file, "class Main { int x = 0; }")
30 );
31 MatcherAssert.assertThat(
32 "Excluded files must not yield violations",
33 new PmdValidator(env).validate(
34 Collections.singletonList(new File(env.basedir(), file))
35 ),
36 Matchers.<Violation>empty()
37 );
38 }
39 }