I'm using C# XUnit in Visual Studio 2019 and I have a test class with various tests, working with databases and a web app. I'd like to run some code that sets up specific DB tables prior running the tests and also cleans afterwards. The catch is that I need this code to run only before and after some specific tests.
- Using InLine params is not possible as these tests don't work with the same content.
- Fixtures are unusable as they work for all the tests.
- EDIT: The tests cannot have a separate class
The ideal case is to have something like:
[For tests with trait XZ]
TestInit(){RUN CODE}
[For tests with trait XZ]
TestCleanup(){RUN CODE]
Is this possible in XUnit or is using a class with extension methods the best possibility?