Skip to content

swift-testing with arguments don't show the issues #402

@Cyberbeni

Description

@Cyberbeni

I am using Linux with Swift 6.0.3

I have this example test file:

import Testing
import Foundation

@Test func example1() async throws {
    #expect(true == false)
}

@Test func example2() async throws {
    throw "some error happened"
}

@Test(arguments: [
    "123"
])
func example3(input1: String) async throws {
    throw "some error happened"
}

@Test(arguments: [
    ("123", "234")
])
func example4(input1: String, input2: String) async throws {
    throw "some error happened"
}

extension String: @retroactive Error {
    var localizedDescription: String {
        self
    }
}

This is the output I get with xcbeautify (latest commit, 6a3819d8183724c94418a7784e47e12a82e30c86):

----- xcbeautify -----
Version: 2.27.0
----------------------

Building for debugging...
[16/16] Linking FoobarPackageTests.xctest
Build complete! (1.57s)
Test Suite 'All tests' started at 2025-03-10 16:47:57.215
Test Suite 'debug.xctest' started at 2025-03-10 16:47:57.216
Test Suite 'debug.xctest' passed at 2025-03-10 16:47:57.216
Test Suite 'All tests' passed at 2025-03-10 16:47:57.216
Test run started.
    ⚠  Test example2() recorded an issue at FoobarTests.swift:8:2: Caught error: some error happened
    ⚠  Test example3(input1:) recorded an issue with 1 argument(s)
    ⚠  Test example1() recorded an issue at FoobarTests.swift:5:5: Expectation failed: true == false
    ⚠  Test example4(input1:input2:) recorded an issue with 2 argument(s)
    ✖ example1() (0.001 seconds) 1 issue(s)
    ✖ example4(input1:input2:) (0.001 seconds) 1 issue(s)
    ✖ example2() (0.001 seconds) 1 issue(s)
    ✖ example3(input1:) (0.001 seconds) 1 issue(s)
Test run with 4 tests failed after 0.001 seconds with 4 issue(s)

This is the raw output:

Building for debugging...
[1/1] Write swift-version-60DE91C8E356094E.txt
Build complete! (0.24s)
Test Suite 'All tests' started at 2025-03-10 16:50:18.036
Test Suite 'debug.xctest' started at 2025-03-10 16:50:18.037
Test Suite 'debug.xctest' passed at 2025-03-10 16:50:18.037
         Executed 0 tests, with 0 failures (0 unexpected) in 0.0 (0.0) seconds
Test Suite 'All tests' passed at 2025-03-10 16:50:18.037
         Executed 0 tests, with 0 failures (0 unexpected) in 0.0 (0.0) seconds
◇ Test run started.
↳ Testing Library Version: 6.0.3 (18c42c19cac3faf)
◇ Test example4(input1:input2:) started.
◇ Test example2() started.
◇ Test example1() started.
◇ Test example3(input1:) started.
✘ Test example2() recorded an issue at FoobarTests.swift:8:2: Caught error: some error happened
◇ Passing 1 argument input1 → "123" to example3(input1:)
✘ Test example2() failed after 0.001 seconds with 1 issue.
◇ Passing 2 arguments input1 → "123", input2 → "234" to example4(input1:input2:)
✘ Test example3(input1:) recorded an issue with 1 argument input1 → "123" at FoobarTests.swift:12:2: Caught error: some error happened
✘ Test example3(input1:) failed after 0.001 seconds with 1 issue.
✘ Test example4(input1:input2:) recorded an issue with 2 arguments input1 → "123", input2 → "234" at FoobarTests.swift:19:2: Caught error: some error happened
✘ Test example4(input1:input2:) failed after 0.001 seconds with 1 issue.
✘ Test example1() recorded an issue at FoobarTests.swift:5:5: Expectation failed: true == false
✘ Test example1() failed after 0.001 seconds with 1 issue.
✘ Test run with 4 tests failed after 0.001 seconds with 4 issues.

Instead of Test example3(input1:) recorded an issue with 1 argument(s), I'd like to see something like Test example3(input1:) recorded an issue with input1 → "123" at FoobarTests.swift:12:2: Caught error: some error happened

Including that it has 1-2-etc. arguments is redundant as I can already see the argument count from the method signature.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions