sevntu-checkstyle/sevntu.checkstyle — pull request #134 by daniilyar (2013-09-10 21:19:12+00:00)
Title: Refactoring of BaseCheckTestsSupport and better support for UTs

What was done:

1. Refactoring of BaseCheckTestsSupport class
2. Update for BaseCheckTestSupport to let UTs retrieve check messages from appropriate 'messages.properties' file instead of excess hardcoding. Example:

instead of "15:45: this is the checkMessage" now we will use it UTs something like this:

public class ForbidAnnotationTest extends BaseCheckTestSupport {

private String msg = getCheckMessage(.MSG_KEY);

@Test
public void testCase() throws Exception
{
DefaultConfiguration checkConfig = createCheckConfig(.class);

checkConfig.addAttribute(... , ...)

final String[] expected = {
buildMesssage(15, 45, "arg1", "arg2"),
};

verify(checkConfig, getPath(""), expected);
}

...

private String buildMesssage(int lineNumber, int columnNumber, String arg1, String arg2) {
return lineNumber + ":" + columnNumber + ": " + MessageFormat.format(msg, arg1, arg2);
}

3. Provided examples of how to use said BaseCheckTestSupport updates:

a. [simple example - no params needed in check message](https://github.com/daniilyar/sevntu.checkstyle/blob/eee8ebe797f7501f94ecf235f853a2f04fba856d/sevntu-checks/src/test/java/com/github/sevntu/checkstyle/checks/coding/NestedTernaryCheckTest.java)
b. [more real-world example - check message has some params](https://github.com/daniilyar/sevntu.checkstyle/blob/eee8ebe797f7501f94ecf235f853a2f04fba856d/sevntu-checks/src/test/java/com/github/sevntu/checkstyle/checks/annotation/ForbidAnnotationTest.java)