Skip to content

Commit f7a685c

Browse files
committed
test: add failing tests for dedup key collision and parameterized case count
Two bugs reproduced: - Test failure dedup key uses only location|message, collapsing distinct failures from different tests sharing the same assertion line - Parameterized test results drop the case count, undercounting progress
1 parent 5b1e785 commit f7a685c

2 files changed

Lines changed: 40 additions & 1 deletion

File tree

src/utils/__tests__/swift-testing-line-parsers.test.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('Swift Testing line parsers', () => {
3333
});
3434
});
3535

36-
it('should parse a passed parameterized test', () => {
36+
it('should parse a passed parameterized test with case count', () => {
3737
const result = parseSwiftTestingResultLine(
3838
'✔ Test "Parameterized test" with 3 test cases passed after 0.001 seconds.',
3939
);
@@ -42,6 +42,20 @@ describe('Swift Testing line parsers', () => {
4242
rawName: 'Parameterized test',
4343
testName: 'Parameterized test',
4444
durationText: '0.001s',
45+
caseCount: 3,
46+
});
47+
});
48+
49+
it('should parse a failed parameterized test with case count', () => {
50+
const result = parseSwiftTestingResultLine(
51+
'✘ Test "Parameterized failure" with 3 test cases failed after 0.001 seconds with 1 issue.',
52+
);
53+
expect(result).toEqual({
54+
status: 'failed',
55+
rawName: 'Parameterized failure',
56+
testName: 'Parameterized failure',
57+
durationText: '0.001s',
58+
caseCount: 3,
4559
});
4660
});
4761

src/utils/__tests__/xcodebuild-run-state.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,31 @@ describe('xcodebuild-run-state', () => {
356356
expect(state.highestStageRank()).toBe(STAGE_RANK.COMPILING);
357357
});
358358

359+
it('does not deduplicate distinct test failures sharing the same assertion location', () => {
360+
const state = createXcodebuildRunState({ operation: 'TEST' });
361+
362+
state.push({
363+
type: 'test-failure',
364+
timestamp: ts(),
365+
operation: 'TEST',
366+
suite: 'SuiteA',
367+
test: 'testOne',
368+
message: 'XCTAssertTrue failed',
369+
location: '/tmp/SharedAssert.swift:10',
370+
});
371+
state.push({
372+
type: 'test-failure',
373+
timestamp: ts(),
374+
operation: 'TEST',
375+
suite: 'SuiteB',
376+
test: 'testTwo',
377+
message: 'XCTAssertTrue failed',
378+
location: '/tmp/SharedAssert.swift:10',
379+
});
380+
381+
expect(state.snapshot().testFailures).toHaveLength(2);
382+
});
383+
359384
it('passes through header and next-steps events', () => {
360385
const forwarded: PipelineEvent[] = [];
361386
const state = createXcodebuildRunState({

0 commit comments

Comments
 (0)