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

Feature: allow test name customisation when using parameters via | operator #581

Open
lgrossi opened this issue Aug 27, 2023 · 0 comments
Open

Comments

@lgrossi
Copy link

lgrossi commented Aug 27, 2023

Expected Behavior

When using parametrization with | operator would be nice to be able to give each test a unique identifier, to make spot of issues easier and to avoid weird behaviors. E.g. when using parametrization with | the number of assertions is way higher than the same set of tests using for();

Actual Behavior

When comparing different ways of adding test parameters, we have:

suite<"more assertions"> a = [] {
	test("MyTest") = [](auto fixture) {
		expect(fixture > 0);
		expect(false);
	} | std::vector{1,2,3,4};
};

suite<"less assertions"> b = [] {
	for(auto fixture : std::vector{1,2,3,4}) {
        test("MyTest" + std::to_string(fixture)) = [&fixture]() {
			expect(fixture > 0);
            expect(false);
        };
    }
};

The first way, using | has two problems: it doesn't allow test name customisation, leaving to warnings during failures, and it creates way more assertions than the second approach.
image
image

Ideally would be nice that both ways have a consistent behavior and that no extra assertions get generated in the print.

Steps to Reproduce the Problem

Running the snapshot above should already give you that.

Specifications

  • Version: v1.1.9
  • Platform: Linux
  • Subsystem: Ubuntu
@lgrossi lgrossi changed the title Parametrization with | operator doesn't allow name customisation Feature: allow test name customisation when using parameters via | operator Aug 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant