use of com.puppycrawl.tools.checkstyle.BaseCheckTestSupport in project checkstyle by checkstyle.
the class AllChecksTest method testAllChecksWithDefaultConfiguration.
@Test
public void testAllChecksWithDefaultConfiguration() throws Exception {
final String inputFilePath = getPath("InputDefaultConfig.java");
final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
for (Class<?> check : CheckUtil.getCheckstyleChecks()) {
final DefaultConfiguration checkConfig = createCheckConfig(check);
final Checker checker;
if (AbstractCheck.class.isAssignableFrom(check)) {
// Checks which have Check as a parent.
if (check.equals(ImportControlCheck.class)) {
// ImportControlCheck must have the import control configuration file to avoid
// violation.
checkConfig.addAttribute("file", getPath("import-control_complete.xml"));
}
checker = createChecker(checkConfig);
} else {
// Checks which have TreeWalker as a parent.
BaseCheckTestSupport testSupport = new BaseCheckTestSupport() {
@Override
protected DefaultConfiguration createCheckerConfig(Configuration config) {
final DefaultConfiguration dc = new DefaultConfiguration("root");
dc.addChild(checkConfig);
return dc;
}
};
checker = testSupport.createChecker(checkConfig);
}
verify(checker, inputFilePath, expected);
}
}
Aggregations