use of com.intellij.junit4.JUnit4TestListener in project intellij-community by JetBrains.
the class JUnitTreeByDescriptionHierarchyTest method doTest.
private static void doTest(Description root, List<Description> tests, String expectedTree, String expectedStart) throws Exception {
final StringBuffer buf = new StringBuffer();
final JUnit4TestListener sender = createListener(buf);
sender.sendTree(root);
Assert.assertEquals("output: " + buf, expectedTree, StringUtil.convertLineSeparators(buf.toString()));
buf.setLength(0);
sender.testRunStarted(root);
for (Description test : tests) {
sender.testStarted(test);
sender.testFinished(test);
}
sender.testRunFinished(new Result());
Assert.assertEquals("output: " + buf, expectedStart, StringUtil.convertLineSeparators(buf.toString()));
}
use of com.intellij.junit4.JUnit4TestListener in project intellij-community by JetBrains.
the class JUnitTreeByDescriptionHierarchyTest method testLongOutputPreservesTestName.
@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.toString()).substring(0, startMessage.length()));
}
use of com.intellij.junit4.JUnit4TestListener in project intellij-community by JetBrains.
the class JUnitTreeByDescriptionHierarchyTest method testPackageWithoutDescriptionBefore.
@Test
public void testPackageWithoutDescriptionBefore() throws Exception {
final Description root = Description.createSuiteDescription("root");
final ArrayList<Description> tests = new ArrayList<>();
for (String className : new String[] { "a.TestA", "a.TestB" }) {
final Description aTestClass = Description.createSuiteDescription(className);
root.addChild(aTestClass);
final Description testDescription = Description.createTestDescription(className, "testName");
aTestClass.addChild(testDescription);
tests.add(testDescription);
}
final StringBuffer buf = new StringBuffer();
final JUnit4TestListener sender = createListener(buf);
sender.testRunStarted(root);
for (Description test : tests) {
sender.testStarted(test);
sender.testFinished(test);
}
sender.testRunFinished(new Result());
Assert.assertEquals("output: " + buf, "##teamcity[enteredTheMatrix]\n" + "\n" + "##teamcity[testSuiteStarted name='TestA' locationHint='java:suite://a.TestA']\n" + "\n" + "##teamcity[testStarted name='TestA.testName' locationHint='java:test://a.TestA.testName']\n" + "\n" + "##teamcity[testFinished name='TestA.testName']\n" + "\n" + "##teamcity[testSuiteFinished name='TestA']\n" + "\n" + "##teamcity[testSuiteStarted name='TestB' locationHint='java:suite://a.TestB']\n" + "\n" + "##teamcity[testStarted name='TestB.testName' locationHint='java:test://a.TestB.testName']\n" + "\n" + "##teamcity[testFinished name='TestB.testName']\n" + "\n" + "##teamcity[testSuiteFinished name='TestB']\n", StringUtil.convertLineSeparators(buf.toString()));
}
use of com.intellij.junit4.JUnit4TestListener in project intellij-community by JetBrains.
the class JUnitTreeByDescriptionHierarchyTest method testClassWithMethodsWithoutSendTreeBefore.
@Test
public void testClassWithMethodsWithoutSendTreeBefore() throws Exception {
Description root = Description.createSuiteDescription("ATest");
List<Description> tests = new ArrayList<>();
tests.add(Description.createTestDescription("ATest", "test1"));
tests.add(Description.createTestDescription("ATest", "test2"));
for (Description test : tests) {
root.addChild(test);
}
final StringBuffer buf = new StringBuffer();
JUnit4TestListener sender = createListener(buf);
sender.testRunStarted(root);
for (Description test : tests) {
sender.testStarted(test);
sender.testFinished(test);
}
sender.testRunFinished(new Result());
Assert.assertEquals("output: " + buf, "##teamcity[enteredTheMatrix]\n" + "\n" + "##teamcity[testSuiteStarted name='ATest' locationHint='java:suite://ATest']\n" + "\n" + "##teamcity[testStarted name='ATest.test1' locationHint='java:test://ATest.test1']\n" + "\n" + "##teamcity[testFinished name='ATest.test1']\n" + "\n" + "##teamcity[testStarted name='ATest.test2' locationHint='java:test://ATest.test2']\n" + "\n" + "##teamcity[testFinished name='ATest.test2']\n" + "\n" + "##teamcity[testSuiteFinished name='ATest']\n", StringUtil.convertLineSeparators(buf.toString()));
}
use of com.intellij.junit4.JUnit4TestListener in project intellij-community by JetBrains.
the class JUnitTreeByDescriptionHierarchyTest method testTearDownClassFailure.
@Test
public void testTearDownClassFailure() throws Exception {
final Description root = Description.createSuiteDescription("root");
final Description testA = Description.createSuiteDescription("TestA");
root.addChild(testA);
final Description testName = Description.createTestDescription("TestA", "testName");
testA.addChild(testName);
final StringBuffer buf = new StringBuffer();
final JUnit4TestListener sender = createListener(buf);
sender.sendTree(root);
Assert.assertEquals("output: " + buf, "##teamcity[enteredTheMatrix]\n" + "##teamcity[suiteTreeStarted name='TestA' locationHint='java:suite://TestA']\n" + "##teamcity[suiteTreeNode name='TestA.testName' locationHint='java:test://TestA.testName']\n" + "##teamcity[suiteTreeEnded name='TestA']\n" + "##teamcity[treeEnded]\n", StringUtil.convertLineSeparators(buf.toString()));
buf.setLength(0);
sender.testRunStarted(testA);
final Exception exception = new Exception();
exception.setStackTrace(new StackTraceElement[0]);
sender.testStarted(testName);
sender.testFinished(testName);
sender.testFailure(new Failure(testA, exception));
sender.testRunFinished(new Result());
Assert.assertEquals("output: " + buf, "##teamcity[rootName name = 'root' location = 'java:suite://root']\n" + "\n" + "##teamcity[testSuiteStarted name='TestA']\n" + "\n" + "##teamcity[testStarted name='TestA.testName' locationHint='java:test://TestA.testName']\n" + "\n" + "##teamcity[testFinished name='TestA.testName']\n" + "\n" + "##teamcity[testStarted name='Class Configuration' locationHint='java:suite://TestA' ]\n" + "\n" + "##teamcity[testFailed name='Class Configuration' details='java.lang.Exception|n' error='true' message='']\n" + "\n" + "##teamcity[testFinished name='Class Configuration']\n" + "\n" + "##teamcity[testSuiteFinished name='TestA']\n", StringUtil.convertLineSeparators(buf.toString()));
}
Aggregations