Skip to content

[QTest] Support for test case data in CheckAllTestCases and RunAllTestCases #2026

Closed
@Manvi-Agrawal

Description

@Manvi-Agrawal

Is your feature request related to a problem? Please describe.
Currently CheckAllTestCases and RunAllTestCases function take a tuple of the form: (name : String, test_case : () -> 'T, expected : 'T). So, Iif someone wants to test a function for multiple inputs/outputs it leads to code duplication.

CheckAllTestCases([
("Should add 1 to 5", () -> AddOne(5), 6),
("Should add 1 to 5", () -> AddOne(6), 7),
]);

function AddOne(x: Int) : Int {
     return x+1;
}

Describe the solution you'd like
Allow CheckAllTestCases and RunAllTestCases function by having input array and expected output array for a function. This is motivated by pytest.mark.parameterize that allows listing inputs and expected outputs

CheckAllTestCases([
("Should add 1 to 5", (x) -> AddOne(x), [5,6], [6, 7]),
]);

function AddOne(x: Int) : Int {
     return x+1;
}

Describe alternatives you've considered
Have duplicate entries in testcases array in CheckAllTestCases and RunAllTestCases function.

Additional context
See #2013 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestlibraryrelated to Q# library code rather than the compiler implementation or language design

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions