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

Parameterized tests and/or custom assertion messages #248

Open
pdesjardins90 opened this issue Feb 4, 2021 · 1 comment
Open

Parameterized tests and/or custom assertion messages #248

pdesjardins90 opened this issue Feb 4, 2021 · 1 comment
Milestone

Comments

@pdesjardins90
Copy link

Sometimes, testing the same code on different datasets is useful. For large datasets, writing a single test for each item in the dataset is exhausting and cumbersome.

Currently, the only smart way to do this is to write a single test, that iterates over an array of test cases:

Ensure(MyTest, testAllTheTings) {
    for (uint8_t index = 0; index < NUMBER_OF_TEST_CASES; ++index) {
        TestCase testCase = TEST_CASES[index];
        uint8_t result = thingDoer()->doThing(testCase.parameter1, testCase.parameter2);
        assert_that(result, is_equal_to(testCase.expectedResult));
    }
}

The problem with this approach is that the new assertion styles do not let you add a custom error message, resulting in error messages that do not tell you which testCase failed. Currently, the only option available is to use the legacy-style assertion assert_equal_with_message.

Adding custom error messages support to the new assertion style would fix this particular issue, but I feel like properly handling parameterized tests would be the better approach. What do you think?

@thoni56
Copy link
Contributor

thoni56 commented Feb 5, 2021

Thank you, Phillippe!

That's a really relevant scenario! It gives me a few ideas that I'd like to ponder for a while. If you have any more concrete ideas from your particular usecase on how to support that, please add them here.

@thoni56 thoni56 added this to the Future milestone May 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants