Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Manvi-Agrawal opened this issue Nov 15, 2024 · 0 comments · May be fixed by #2037
Open

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

Manvi-Agrawal opened this issue Nov 15, 2024 · 0 comments · May be fixed by #2037
Labels
enhancement New feature or request library related to Q# library code rather than the compiler implementation or language design

Comments

@Manvi-Agrawal
Copy link
Contributor

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)

@Manvi-Agrawal Manvi-Agrawal added enhancement New feature or request needs triage labels Nov 15, 2024
@sezna sezna linked a pull request Nov 18, 2024 that will close this issue
@sezna sezna added library related to Q# library code rather than the compiler implementation or language design and removed needs triage labels Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request library related to Q# library code rather than the compiler implementation or language design
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants