Search in sources :

Example 1 with TestCase

use of com.google.idea.blaze.base.run.smrunner.BlazeXmlSchema.TestCase in project intellij by bazelbuild.

the class BlazeXmlToTestEventsConverter method processTestSuite.

private static void processTestSuite(GeneralTestEventsProcessor processor, BlazeTestEventsHandler eventsHandler, @Nullable Kind kind, TestSuite suite) {
    if (!hasRunChild(suite)) {
        return;
    }
    // only include the innermost 'testsuite' element
    boolean logSuite = !eventsHandler.ignoreSuite(kind, suite);
    if (suite.name != null && logSuite) {
        TestSuiteStarted suiteStarted = new TestSuiteStarted(eventsHandler.suiteDisplayName(kind, suite.name));
        String locationUrl = eventsHandler.suiteLocationUrl(kind, suite.name);
        processor.onSuiteStarted(new TestSuiteStartedEvent(suiteStarted, locationUrl));
    }
    for (TestSuite child : suite.testSuites) {
        processTestSuite(processor, eventsHandler, kind, child);
    }
    for (TestSuite decorator : suite.testDecorators) {
        processTestSuite(processor, eventsHandler, kind, decorator);
    }
    for (TestCase test : suite.testCases) {
        processTestCase(processor, eventsHandler, kind, suite, test);
    }
    if (suite.sysOut != null) {
        processor.onUncapturedOutput(suite.sysOut, ProcessOutputTypes.STDOUT);
    }
    if (suite.sysErr != null) {
        processor.onUncapturedOutput(suite.sysErr, ProcessOutputTypes.STDERR);
    }
    if (suite.name != null && logSuite) {
        processor.onSuiteFinished(new TestSuiteFinishedEvent(eventsHandler.suiteDisplayName(kind, suite.name)));
    }
}
Also used : TestSuiteStarted(jetbrains.buildServer.messages.serviceMessages.TestSuiteStarted) TestSuite(com.google.idea.blaze.base.run.smrunner.BlazeXmlSchema.TestSuite) TestCase(com.google.idea.blaze.base.run.smrunner.BlazeXmlSchema.TestCase) TestSuiteStartedEvent(com.intellij.execution.testframework.sm.runner.events.TestSuiteStartedEvent) TestSuiteFinishedEvent(com.intellij.execution.testframework.sm.runner.events.TestSuiteFinishedEvent)

Example 2 with TestCase

use of com.google.idea.blaze.base.run.smrunner.BlazeXmlSchema.TestCase in project intellij by bazelbuild.

the class BlazeXmlSchemaTest method testTestCaseWithMultipleFailures.

@Test
public void testTestCaseWithMultipleFailures() {
    TestSuite parsed = parseXml("<?xml version='1.0' encoding='UTF-8'?>", "<testsuites>", "  <testsuite name='com.google.ConfigTest' time='10' tests='2' failures='1'>", "    <testcase name='testCase1' time='7.9' status='run' result='completed'>", "      <failure message='failed' type='AssertionError'>Error message</failure>", "      <failure message='failed2' type='AssertionError'>Another Error</failure>", "    </testcase>", "  </testsuite>", "</testsuites>");
    assertThat(parsed.testSuites.get(0).testCases).hasSize(1);
    assertThat(parsed.testSuites.get(0).failures).isEqualTo(1);
    TestCase testCase = parsed.testSuites.get(0).testCases.get(0);
    assertThat(testCase.failures).hasSize(2);
    assertThat(testCase.failures.get(0).message).isEqualTo("failed");
    assertThat(testCase.failures.get(0).content).isEqualTo("Error message");
    assertThat(testCase.failures.get(1).message).isEqualTo("failed2");
    assertThat(testCase.failures.get(1).content).isEqualTo("Another Error");
}
Also used : TestSuite(com.google.idea.blaze.base.run.smrunner.BlazeXmlSchema.TestSuite) TestCase(com.google.idea.blaze.base.run.smrunner.BlazeXmlSchema.TestCase) Test(org.junit.Test)

Example 3 with TestCase

use of com.google.idea.blaze.base.run.smrunner.BlazeXmlSchema.TestCase in project intellij by bazelbuild.

the class BlazeXmlSchemaTest method testMergeShardedTests.

@Test
public void testMergeShardedTests() {
    TestSuite shard1 = parseXml("<?xml version='1.0' encoding='UTF-8'?>", "<testsuites>", "  <testsuite name='com.google.ConfigTest' time='10' tests='2' failures='1'>", "    <testcase name='testCase1' time='2.1' status='run' result='completed'/>", "    <testcase name='testCase2' time='7.9' status='run' result='completed'>", "      <failure message='failed'/>", "    </testcase>", "  </testsuite>", "</testsuites>");
    TestSuite shard2 = parseXml("<?xml version='1.0' encoding='UTF-8'?>", "<testsuites>", "  <testsuite name='com.google.ConfigTest' time='5' tests='2' failures='1'>", "    <testcase name='testCase3' time='1' status='run' result='completed'/>", "    <testcase name='testCase4' time='4' status='run' result='completed'>", "      <failure message='failed'/>", "    </testcase>", "  </testsuite>", "</testsuites>");
    TestSuite mergedOuter = BlazeXmlSchema.mergeSuites(ImmutableList.of(shard1, shard2));
    assertThat(mergedOuter.testSuites).hasSize(1);
    TestSuite mergedInner = mergedOuter.testSuites.get(0).testSuites.get(0);
    assertThat(mergedInner.name).isEqualTo("com.google.ConfigTest");
    assertThat(mergedInner.time).isEqualTo(15d);
    assertThat(mergedInner.tests).isEqualTo(4);
    assertThat(mergedInner.failures).isEqualTo(2);
    assertThat(mergedInner.testCases).hasSize(4);
    assertThat(mergedInner.testCases.stream().map(testCase -> testCase.name).collect(Collectors.toList())).containsExactly("testCase1", "testCase2", "testCase3", "testCase4");
}
Also used : TestCase(com.google.idea.blaze.base.run.smrunner.BlazeXmlSchema.TestCase) ImmutableList(com.google.common.collect.ImmutableList) ByteArrayInputStream(java.io.ByteArrayInputStream) RunWith(org.junit.runner.RunWith) Test(org.junit.Test) TestSuite(com.google.idea.blaze.base.run.smrunner.BlazeXmlSchema.TestSuite) JUnit4(org.junit.runners.JUnit4) Truth.assertThat(com.google.common.truth.Truth.assertThat) Collectors(java.util.stream.Collectors) StandardCharsets(java.nio.charset.StandardCharsets) Joiner(com.google.common.base.Joiner) InputStream(java.io.InputStream) TestSuite(com.google.idea.blaze.base.run.smrunner.BlazeXmlSchema.TestSuite) Test(org.junit.Test)

Aggregations

TestCase (com.google.idea.blaze.base.run.smrunner.BlazeXmlSchema.TestCase)3 TestSuite (com.google.idea.blaze.base.run.smrunner.BlazeXmlSchema.TestSuite)3 Test (org.junit.Test)2 Joiner (com.google.common.base.Joiner)1 ImmutableList (com.google.common.collect.ImmutableList)1 Truth.assertThat (com.google.common.truth.Truth.assertThat)1 TestSuiteFinishedEvent (com.intellij.execution.testframework.sm.runner.events.TestSuiteFinishedEvent)1 TestSuiteStartedEvent (com.intellij.execution.testframework.sm.runner.events.TestSuiteStartedEvent)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 StandardCharsets (java.nio.charset.StandardCharsets)1 Collectors (java.util.stream.Collectors)1 TestSuiteStarted (jetbrains.buildServer.messages.serviceMessages.TestSuiteStarted)1 RunWith (org.junit.runner.RunWith)1 JUnit4 (org.junit.runners.JUnit4)1