void () { StringBuilder buf = new StringBuilder(); for (int i = 0; i < 1000; i++) { buf.append(DebugUtil.currentStackTrace()); } final StringBuffer output = new StringBuffer(); final JUnit4TestListener sender = createListener(output); final Description description = Description.createTestDescription("A", "a"); sender.testFailure(new Failure(description, new ComparisonFailure(buf.toString(), buf.toString(), "diff" + buf))); final String startMessage = "##teamcity[enteredTheMatrix]\n" + "##teamcity[testFailed name='A.a' "; Assert.assertEquals(startMessage, StringUtil.convertLineSeparators(output.toString()).substring(0, startMessage.length())); }