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)));
}
}
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");
}
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");
}
Aggregations