Source:
<code>public void testExistingTargetFileWithError() throws Exception { exit.expectSystemExitWithStatus(2); exit.checkAssertionAfterwards(() -> { final LocalizedMessage auditStartMessage = new LocalizedMessage(0, Definitions.CHECKSTYLE_BUNDLE, "DefaultLogger.auditStarted", null, null, getClass(), null); final LocalizedMessage auditFinishMessage = new LocalizedMessage(0, Definitions.CHECKSTYLE_BUNDLE, "DefaultLogger.auditFinished", null, null, getClass(), null); final LocalizedMessage errorCounterMessage = new LocalizedMessage(0, Definitions.CHECKSTYLE_BUNDLE, "Main.errorCounter", new String[] {String.valueOf(2)}, null, getClass(), null); final LocalizedMessage invalidPatternMessageMain = new LocalizedMessage(0, "com.puppycrawl.tools.checkstyle.checks.naming.messages", <START> "name.invalidPattern", new String[] {"InputMain", "^[a-z0-9]*$"}, <END> null, getClass(), null); final LocalizedMessage invalidPatternMessageMainInner = new LocalizedMessage(0, "com.puppycrawl.tools.checkstyle.checks.naming.messages", "name.invalidPattern", new String[] {"InputMainInner", "^[a-z0-9]*$"}, null, getClass(), null); final String expectedPath = getFilePath("InputMain.java"); assertEquals(String.format(Locale.ROOT, auditStartMessage.getMessage() + "%n" + "[ERROR] %1$s:3:14: " + invalidPatternMessageMain.getMessage() + " [TypeName]%n" + "[ERROR] %1$s:5:7: " + invalidPatternMessageMainInner.getMessage() + " [TypeName]%n" + auditFinishMessage.getMessage() + "%n" + errorCounterMessage.getMessage() + "%n", expectedPath), systemOut.getLog()); assertEquals("", systemErr.getLog()); }); Main.main("-c", getPath("config-classname2-error.xml"), getPath("InputMain.java")); }</code><technical_language>@rnveach , I do class fields for Tests, I moving auditStartMessage/auditFinishMessage other string parameters Test classfields is reasonable</technical_language>

Target:
public void testExistingTargetFileWithError() throws Exception { exit.expectSystemExitWithStatus(2); exit.checkAssertionAfterwards(() -> { final LocalizedMessage errorCounterTwoMessage = new LocalizedMessage(0, Definitions.CHECKSTYLE_BUNDLE, "Main.errorCounter", new String[] {String.valueOf(2)}, null, getClass(), null); final LocalizedMessage invalidPatternMessageMain = new LocalizedMessage(0, "com.puppycrawl.tools.checkstyle.checks.naming.messages", "name.invalidPattern", new String[] {"InputMain", "^[a-z0-9]*$"}, null, getClass(), null); final LocalizedMessage invalidPatternMessageMainInner = new LocalizedMessage(0, "com.puppycrawl.tools.checkstyle.checks.naming.messages", "name.invalidPattern", new String[] {"InputMainInner", "^[a-z0-9]*$"}, null, getClass(), null); final String expectedPath = getFilePath("InputMain.java"); assertEquals(auditStartMessage.getMessage() + EOL + "[ERROR] " + expectedPath + ":3:14: " + invalidPatternMessageMain.getMessage() + " [TypeName]" + EOL + "[ERROR] " + expectedPath + ":5:7: " + invalidPatternMessageMainInner.getMessage() + " [TypeName]" + EOL + auditFinishMessage.getMessage() + EOL + errorCounterTwoMessage.getMessage() + EOL, systemOut.getLog()); assertEquals("", systemErr.getLog()); }); Main.main("-c", getPath("config-classname2-error.xml"), getPath("InputMain.java")); }