jeudi 8 juin 2017

How to specify a predefined list of elements for xUnit's Combinatorial?

I'm using Xunit.Combinatorial and the syntax of the test I'm setting up looks something like this.

[Theory, CombinatorialData]
public void GivenCondition_WhenDoing_ThenExpect(
  [CombinatorialValues("monkey", "donkey", "wonkey")] string beep)
{ ... }

Now, I just realized that my inputs won't be strings but certain enums, which makes for input as the atrocity presented below.

[Theory, CombinatorialData]
public void GivenCondition_WhenDoing_ThenExpect(
  [CombinatorialValues(SomeEnum.Uno, SomeEnum.Duo, SomeEnum.Tri)] SomeEnum beep)
{ ... }

Now, imagine that SomeEnum is CalculationEstimateValuePeriodicity and that there are x-teen of such to list. It's not an acceptable working condition for my lazy donkey.

(How) can I predefine all the lists that I then can use for orchestrating the test suite nicer? I'd love to specify a property with such a predefined list of enum values into the CombinatorialValues attribute.

I'd googled it but xUnit seems to be a bit flatter in its facilities compared to nUnit, sadly. Even the combinatorial setup needed an external package...

Aucun commentaire:

Enregistrer un commentaire