Skip to content

swift test output does not differentiate tests with the same name from different suites #841

Open
@jmschonfeld

Description

@jmschonfeld

Description

Given I have two test suites that look like the following:

struct Day01Tests {
    @Test func part1() { /* ... */ }
    @Test func part2() { /* ... */ }
}

struct Day02Tests {
    @Test func part1() { /* ... */ }
    @Test func part2() { /* ... */ }
}

The output of swift test does not allow the reader to distinguish between the two part1 tests in separate test suites. I encountered this when working on my AdventOfCode project, but I think there's a variety of projects that use generic function names for tests (think testEquatable/testHashable in suites for each publicly defined type) that would need to differentiate between these tests.

Is there a way the output could differentiate? IIRC XCTest fully qualified the test names with the suite names, but I might be wrong on that

Expected behavior

I expect that the produced output of swift test would differentiate (potentially via fully qualifying) tests with the same name in different suites

Actual behavior

Tests are not differentiated:

􀟈 Test run started.
􀄵 Testing Library Version: 102 (arm64e-apple-macos13.0)
􀟈 Suite Day01Tests started.
􀟈 Suite Day02Tests started.
􀟈 Test part1() started.
􀟈 Test part2() started.
􀟈 Test part1() started.
􀟈 Test part2() started.
􁁛 Test part2() passed after 0.001 seconds.
􁁛 Test part1() passed after 0.001 seconds.
􁁛 Test part1() passed after 0.001 seconds.
􁁛 Test part2() passed after 0.001 seconds.
􁁛 Suite Day02Tests passed after 0.011 seconds.
􁁛 Suite Day01Tests passed after 0.011 seconds.
􁁛 Test run with 8 tests passed after 0.011 seconds.

Steps to reproduce

  1. Add the sample code above to a swift package
  2. Run tests in Xcode (or presumably with swift test as well)

swift-testing version/commit hash

Testing Library Version: 102 (arm64e-apple-macos13.0)

Swift & OS version (output of swift --version ; uname -a)

Xcode 16.1 (16B40) on macOS 15.1.1 (24B91)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions