Add test coverage to JavadocPackage check. #1308
This commit is contained in:
parent
ef540c2c72
commit
b9702a2c99
1
pom.xml
1
pom.xml
|
|
@ -1151,7 +1151,6 @@
|
|||
<regex><pattern>.*.checks.javadoc.AbstractJavadocCheck\$.*</pattern><branchRate>50</branchRate><lineRate>68</lineRate></regex>
|
||||
<regex><pattern>.*.checks.javadoc.AtclauseOrderCheck</pattern><branchRate>88</branchRate><lineRate>88</lineRate></regex>
|
||||
<regex><pattern>.*.checks.javadoc.JavadocMethodCheck</pattern><branchRate>91</branchRate><lineRate>98</lineRate></regex>
|
||||
<regex><pattern>.*.checks.javadoc.JavadocPackageCheck</pattern><branchRate>80</branchRate><lineRate>95</lineRate></regex>
|
||||
<regex><pattern>.*.checks.javadoc.JavadocParagraphCheck</pattern><branchRate>92</branchRate><lineRate>100</lineRate></regex>
|
||||
<regex><pattern>.*.checks.javadoc.JavadocStyleCheck</pattern><branchRate>89</branchRate><lineRate>98</lineRate></regex>
|
||||
<regex><pattern>.*.checks.javadoc.JavadocTypeCheck</pattern><branchRate>95</branchRate><lineRate>93</lineRate></regex>
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@ import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
|
|||
import com.puppycrawl.tools.checkstyle.api.Configuration;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocPackageCheck.MSG_LEGACY_PACKAGE_HTML;
|
||||
import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocPackageCheck.MSG_PACKAGE_INFO;
|
||||
|
||||
|
|
@ -50,6 +52,35 @@ public class JavadocPackageCheckTest
|
|||
expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMissingWithAllowLegacy() throws Exception {
|
||||
final DefaultConfiguration checkConfig = createCheckConfig(JavadocPackageCheck.class);
|
||||
checkConfig.addAttribute("allowLegacy", "true");
|
||||
final String[] expected = {
|
||||
"0: " + getCheckMessage(MSG_PACKAGE_INFO),
|
||||
};
|
||||
verify(
|
||||
createChecker(checkConfig),
|
||||
getSrcPath("checks/javadoc/BadCls.java"),
|
||||
getSrcPath("checks/javadoc/BadCls.java"),
|
||||
expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithMultipleFiles() throws Exception {
|
||||
final Configuration checkConfig = createCheckConfig(JavadocPackageCheck.class);
|
||||
final String path1 = getPath("javadoc/InputNoJavadoc.java");
|
||||
final String path2 = getPath("javadoc/InputBadTag.java");
|
||||
final String[] expected = {
|
||||
"0: " + getCheckMessage(MSG_PACKAGE_INFO),
|
||||
};
|
||||
verify(
|
||||
createChecker(checkConfig),
|
||||
new File[] {new File(path1), new File(path2)},
|
||||
path1,
|
||||
expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBoth() throws Exception {
|
||||
final Configuration checkConfig = createCheckConfig(JavadocPackageCheck.class);
|
||||
|
|
|
|||
Loading…
Reference in New Issue