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

Allow veto of certain combinations #3

Open
AArnott opened this issue Dec 6, 2015 · 12 comments
Open

Allow veto of certain combinations #3

AArnott opened this issue Dec 6, 2015 · 12 comments

Comments

@AArnott
Copy link
Owner

AArnott commented Dec 6, 2015

PairwiseDataAttribute and CombinatorialDataAttribute should accept a parameter that allows the test to veto certain known invalid parameter combinations. Thereby suppressing generation of test cases that don't make sense.

Ideally in the pairwise case, such a suppression will feed back into the pairwise algorithm so it can try selecting other combinations that still satisfy pairwise testing requirements, wherever possible.

@ilyabreev
Copy link

+1 for this feature. It seems not really hard to implement it at least for CombinatorialDataAttribute.

@alrz
Copy link

alrz commented Jun 1, 2021

+1

Currently we have to do switch (param1, param2) { case (invalid, combinations): .. return; } which doesn't prevent redundant test runs.

@AArnott
Copy link
Owner Author

AArnott commented Jun 1, 2021

Can someone make a proposal that includes the new API surface area, example uses and describe the behavior?

@alrz
Copy link

alrz commented Jun 1, 2021

This is the simplest I could come up with

[Theory, CombinatorialData]
[CombinatiorialExclude(false, false, false)]
// maybe a few more
public void CheckValidAge(bool p1, bool p2, bool p3)

to exclude (false, false, false) test case.

Something similar should probably work for pairwise, but I don't have a good use case for it right now.

@AArnott
Copy link
Owner Author

AArnott commented Jun 2, 2021

That's a good start. What about when the args can't be expressed as constants? Something like MemberData provides. Or maybe that already doesn't work for Combinatorial, I don't recall.

@alrz
Copy link

alrz commented Jun 2, 2021

What about when the args can't be expressed as constants? Something like MemberData provides. Or maybe that already doesn't work for Combinatorial,

Even if it does work, that may need a special equality check as well so it's probably out of scope. I think an attribute like that will cover 90% of scenarios.

@AArnott
Copy link
Owner Author

AArnott commented Jun 11, 2021

#1 actually tracks a MemberData-like attribute and it looks like we may have a volunteer for contributing it soon.

@AndrewKitu
Copy link

Maybe to add 2 different attributes?

CombinatiorialExclude for constants and CombinatiorialExcludeMemberData for complex data.

[Theory, CombinatorialData]
[CombinatiorialExclude(1, 1, 1)]
public void CheckFailIfAnyParamIsNonpositive(
    [CombinatorialValues(-1, 0, 1)] int a, 
    [CombinatorialValues(-1, 0, 1)] int b, 
    [CombinatorialValues(-1, 0, 1)] int c)
[Theory, CombinatorialData]
[CombinatiorialExcludeMemberData(nameof(GetUntestableCombinations))]
public void CheckComplexParameters(
    [CombinatorialMemberDataValues(nameof(GetComplexData1))] Complex1 complex1, 
    [CombinatorialMemberDataValues(nameof(GetComplexData2))] Complex2 complex2)

@AArnott
Copy link
Owner Author

AArnott commented Oct 26, 2021

Sure, that could work.

@AArnott AArnott closed this as completed in 26696c1 Nov 9, 2022
@alrz
Copy link

alrz commented Feb 26, 2023

26696c1 doesn't seem to be related?

@AArnott AArnott reopened this Feb 26, 2023
@AArnott
Copy link
Owner Author

AArnott commented Feb 26, 2023

Agreed. That's a mistake from merging commits from another repo. Thanks for catching, @alrz.

@relfman-cmg
Copy link

relfman-cmg commented Apr 5, 2023

+1

Personally I would need something like [CombinatiorialExcludeMemberData(nameof(GetUntestableCombinations))]

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

5 participants