When you want to test a lot of variations for a single input value.
If you have more than parameter that you want to vary, check out Testing Combinations.
- Copy this starter text.
TEST_CASE("VerifyAllStartingPoint")
{
std::vector<std::string> inputs{"input.value1", "input.value2"};
ApprovalTests::Approvals::verifyAll("TITLE", inputs, [](auto input, auto& stream) {
stream << input << " => "
<< "placeholder";
});
}
- Modify the input container for your chosen values.
- Run it, and make sure that you have your inputs wired up correctly.
If they are wired up correctly, you will see a file that looks like this: it is the left hand side of the file that matters at this point: all combinations of your own input values should be listed:
TITLE
input.value1 => placeholder
input.value2 => placeholder
- Replace the "placeholder" with a call to the functionality that you want to test.
- Change the TITLE to something meaningful
- Run it, and approve the output.
For advice on effective formatting, see Tips for Designing Strings. As you write out larger volumes of data in your approval files, experience has shown that the choice of layout of text in approval files can make a big difference to maintainability of tests, when failures occur.