fsprojects / TickSpec

Lean .NET BDD framework with powerful F# integration
Apache License 2.0
133 stars 23 forks source link

TickSpec+XUnit: Tagged scenarios filtering in dotnet test possible? #37

Closed deyanp closed 3 years ago

deyanp commented 4 years ago

I saw that you can tag scenarios with @tag1 and @tag2, but is it possible to filter the tests to be executed by @tag1 with dotnet test --filter?

I am using TickSpec with XUnit.

mchaloupka commented 4 years ago

Hi,

this purely depends on how do you use the TickSpec. We do not force any kind of usage as it may differ for specific use cases. I do not have a significant experience with xUnit, but if you look how the NUnit wiring is done, you may get the overall idea: https://github.com/fsprojects/TickSpec/blob/master/Examples/ByFramework/NUnit/CSharp.NUnit/NUnitWiring.cs#L36

Specifically the following line wires the individual tests:

scenarios.Select(s => (new TestCaseData(s)).SetName(s.Name).SetProperty("Feature", feature.Name.Substring(9)));

The scenarios is provided by Tickspec and there is a property Tags (list of strings) where do you have the tags available. It collects all of them for you (from the feature, from samples and from scenario). It just depends whether you are able to provide these tags to xUnit anyhow so you can filter upon them. If you find a way to do that in xUnit, please feel free to contribute back. There are examples, this could be another nice example of a wiring for xUnit.

mchaloupka commented 3 years ago

I’m closing this issue because it has been inactive for a few months. Feel free to reopen if you need further help. Similarly, in case you solved it for xUnit, consider sharing it as sample for others. Thanks!