void () { mySplitter.process("\nStarting...\n##teamcity[name1]\nDone 1\n\n##teamcity[name2]\nDone 2", ProcessOutputTypes.STDOUT); mySplitter.process("##teamcity[name3]\nTest print##teamcity[message key='spam']\n", ProcessOutputTypes.STDOUT); mySplitter.process("##teamcity[name5]\n", ProcessOutputTypes.STDOUT); mySplitter.process("##teamcity[name6]\nInfo##teamcity[name7]\n", ProcessOutputTypes.STDOUT); final String[] stdout = myOutput.get(ProcessOutputTypes.STDOUT).toArray(); Assert.assertArrayEquals(new String[]{ "\n", "Starting...\n", "##teamcity[name1]\n", "Done 1\n", "\n", "##teamcity[name2]\n", "Done 2", "##teamcity[name3]\n", "Test print", "##teamcity[message key='spam']\n", "##teamcity[name5]\n", "##teamcity[name6]\n", "Info", "##teamcity[name7]\n" }, stdout); for (String prefix : new String[]{"...", "", "... ", "##", " ##", "##team##teamcity[foo]\n"}) { final String testStarted = ServiceMessageBuilder.testStarted("myTest").toString(); final String testEnded = ServiceMessageBuilder.testFinished("myTest").toString(); mySplitter.process(prefix, ProcessOutputTypes.STDOUT); mySplitter.process(prefix + testStarted, ProcessOutputTypes.STDOUT); mySplitter.process(testEnded, ProcessOutputTypes.STDOUT); mySplitter.flush(); final List<String> output = myOutput.get(ProcessOutputTypes.STDOUT).toList(); final String messagePrefix = ServiceMessage.SERVICE_MESSAGE_START; Assert.assertThat(output, everyItem(either(startsWith(messagePrefix)).or(not(containsString(messagePrefix))))); Assert.assertThat(output, hasItems(testStarted, testEnded)); myOutput.clear(); } }