Skip to content

Test arguments generated with "Int.random(...)" are not passed #1222

@VinceBurn

Description

@VinceBurn

Description

@Test(
     ...
    arguments: [Int.random(in: Int.min ... -2), -1, 12, Int.random(in: 13 ... Int.max)],
)

The above test arguments produces this: [-1, 12] instead of [random, -1, 12, random]

Reproduction

@Test(
    "Unsupported File Value",
    arguments: [Int.random(in: Int.min ... -2), -1, 12, Int.random(in: 13 ... Int.max)],
)
func unsupportedFileValue(file: Int) async throws
{
    let sut = Coordinate2D(file, 1)
    #expect(sut.notation == "_1", "Unsupported File, any value not in 0...10, is Represented by '_'")
}

The above code will call the test function 2 times instead of 4, with only the Int literal values [-1, 12], ignoring the Int.random(in:) results.

Expected behavior

@Test(
     ...
    arguments: [Int.random(in: Int.min ... -2), -1, 12, Int.random(in: 13 ... Int.max)],
)

The above test arguments produces this: [-1, 12] instead of [random, -1, 12, random].

I would expect [randomInt, -1, 12, randomInt] e.x [-101, -1, 12, 2345].

Environment

Swift Testing
Testing Library Version: 124.4
Target Platform: arm64e-apple-macos14.0

swift-driver version: 1.120.5 Apple Swift version 6.1.2 (swiftlang-6.1.2.1.2 clang-1700.0.13.5)
Target: arm64-apple-macosx15.0

Darwin Kernel Version 24.5.0: Tue Apr 22 19:54:49 PDT 2025

Xcode
Version 26.0 beta 3 (17A5276g)

Additional information

That behaviour is strange to me as the following code behave correctly:

@Test(
    "Test",
    arguments: [UUID().uuidString, UUID().uuidString]
)
func test(_ rank: String) async throws
{
    print(rank)
}

And this also behave correctly

@Test(
    "All Valid File, 'a' to 'l'",
    arguments: zip(
        Array(0 ... 11),
        ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l"],
    ),
)

Metadata

Metadata

Assignees

Labels

bug🪲 Something isn't workingparameterized-testingRelated to parameterized testing functionality

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy