mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
junit: ensure test failure name is passed even for too long truncated lines
This commit is contained in:
+23
@@ -17,7 +17,9 @@ package com.intellij.execution.junit;
|
||||
|
||||
import com.intellij.junit4.JUnit4TestListener;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.impl.DebugUtil;
|
||||
import junit.framework.Assert;
|
||||
import org.junit.ComparisonFailure;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.Description;
|
||||
import org.junit.runner.Result;
|
||||
@@ -30,6 +32,9 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class JUnitTreeByDescriptionHierarchyTest {
|
||||
@Test
|
||||
public void testEmptySuite() throws Exception {
|
||||
@@ -465,6 +470,24 @@ public class JUnitTreeByDescriptionHierarchyTest {
|
||||
"##teamcity[testSuiteFinished name='TestA']\n", StringUtil.convertLineSeparators(buf.toString()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLongOutputPreservesTestName() throws Exception {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
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.toString())));
|
||||
|
||||
final String startMessage = "##teamcity[enteredTheMatrix]\n\n" +
|
||||
"##teamcity[testFailed name='A.a' ";
|
||||
assertEquals(startMessage, StringUtil.convertLineSeparators(output.substring(0, startMessage.length() + 1)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParallelExecution() throws Exception {
|
||||
final Description root = Description.createSuiteDescription("root");
|
||||
|
||||
@@ -268,7 +268,7 @@ public class JUnit4TestListener extends RunListener {
|
||||
return;
|
||||
}
|
||||
|
||||
final Map attrs = new HashMap();
|
||||
final Map attrs = new LinkedHashMap();
|
||||
attrs.put("name", methodName);
|
||||
final long duration = currentTime() - myCurrentTestStart;
|
||||
if (duration > 0) {
|
||||
|
||||
Reference in New Issue
Block a user