diff --git a/Bluepill-runner/Bluepill-runner/BPReportCollector.m b/Bluepill-runner/Bluepill-runner/BPReportCollector.m index 0dd5c732..a47bb355 100644 --- a/Bluepill-runner/Bluepill-runner/BPReportCollector.m +++ b/Bluepill-runner/Bluepill-runner/BPReportCollector.m @@ -209,8 +209,17 @@ + (void)collateTestSuiteTestCases:(NSXMLElement *)testSuite into:(NSXMLElement * if (targetTestCase) { [BPUtils printInfo:DEBUGINFO withString:@"testcase match: %@", [[targetTestCase attributeForName:@"name"] stringValue]]; parent = (NSXMLElement *)[targetTestCase parent]; - // append the latest result - [parent insertChild:[testCase copy] atIndex:[targetTestCase index] + 1]; + // append the latest result at the end + NSUInteger insertIndex; + for (insertIndex = [targetTestCase index]; insertIndex < [[parent children] count]; insertIndex++) { + NSXMLElement *currentTestCase = (NSXMLElement *)[[parent children] objectAtIndex:insertIndex]; + NSString *thisName = [[currentTestCase attributeForName:@"name"] stringValue]; + NSString *thisClassName = [[currentTestCase attributeForName:@"classname"] stringValue]; + if ([name isNotEqualTo:thisName] || [className isNotEqualTo:thisClassName]) { + break; + } + } + [parent insertChild:[testCase copy] atIndex:insertIndex]; } else { [BPUtils printInfo:DEBUGINFO withString:@"testcase insertion: %@", [[testCase attributeForName:@"name"] stringValue]]; [targetTestSuite addChild:[testCase copy]]; diff --git a/Bluepill-runner/BluepillRunnerTests/BPReportCollectorTests.m b/Bluepill-runner/BluepillRunnerTests/BPReportCollectorTests.m index 84bf52ab..3af27bb1 100644 --- a/Bluepill-runner/BluepillRunnerTests/BPReportCollectorTests.m +++ b/Bluepill-runner/BluepillRunnerTests/BPReportCollectorTests.m @@ -79,12 +79,26 @@ - (void)testCollectReportsFromPath { NSArray *testsuitesNodes = [doc nodesForXPath:[NSString stringWithFormat:@".//%@", @"testsuites"] error:&error]; NSXMLElement *root = testsuitesNodes[0]; NSString *got = [[root attributeForName:@"tests"] stringValue]; - - XCTAssertTrue([got isEqualToString:@"25"], @"test count is wrong, wanted 25, got %@", got); + NSString *want = @"26"; + XCTAssertTrue([got isEqualToString:want], @"test count is wrong, wanted %@, got %@", want, got); got = [[root attributeForName:@"errors"] stringValue]; - XCTAssertTrue([got isEqualToString:@"2"], @"error count is wrong, wanted 2, got %@", got); + want = @"2"; + XCTAssertTrue([got isEqualToString:want], @"error count is wrong, wanted %@, got %@", want, got); got = [[root attributeForName:@"failures"] stringValue]; - XCTAssertTrue([got isEqualToString:@"2"], @"failure count is wrong, wanted 2, got %@", got); + want = @"3"; + XCTAssertTrue([got isEqualToString:want], @"failure count is wrong, wanted %@, got %@", want, got); + + // make sure the order is right + NSArray *retriedTests = [doc nodesForXPath:@"//testcase[@name='test2' and @classname='Class1']" error:nil]; + XCTAssert(retriedTests.count == 3, @"Did not find three tries for test2"); + XCTAssert([[retriedTests[0] nodesForXPath:@"failure" error:nil] count] == 1, @"First was not a failure"); + XCTAssert([[retriedTests[1] nodesForXPath:@"failure" error:nil] count] == 1, @"Second was not a failure"); + XCTAssert([[retriedTests[2] nodesForXPath:@"failure" error:nil] count] == 0, @"Third was not a success"); + + + char * cmd = malloc(1024 * 10); + sprintf(cmd, "open -a '/Applications/Visual Studio Code.app' -- '%s'", [finalReport UTF8String]); + system(cmd); BOOL collatedReport = [[NSFileManager defaultManager] fileExistsAtPath:[path stringByAppendingPathComponent:@"1/report1.xml"]]; XCTAssert(collatedReport == NO); diff --git a/Bluepill-runner/BluepillRunnerTests/simulator/3/result3.xml b/Bluepill-runner/BluepillRunnerTests/simulator/3/result3.xml index cf8eb950..af6b70eb 100644 --- a/Bluepill-runner/BluepillRunnerTests/simulator/3/result3.xml +++ b/Bluepill-runner/BluepillRunnerTests/simulator/3/result3.xml @@ -1,8 +1,11 @@ - - - + + + + + Unknown File:0 + diff --git a/Bluepill-runner/BluepillRunnerTests/simulator/4/result4.xml b/Bluepill-runner/BluepillRunnerTests/simulator/4/result4.xml index 106403cc..7cf09c07 100644 --- a/Bluepill-runner/BluepillRunnerTests/simulator/4/result4.xml +++ b/Bluepill-runner/BluepillRunnerTests/simulator/4/result4.xml @@ -1,7 +1,11 @@ - - - + + + + + + +