I have tests written in XUnit using the InlineData and MemberData attributes. I would like to run tests using code elsewhere in my project and have attributes that automatically populate the test data, as usual when they run through the VS test runner.
If not for the attributes, I would just call the methods directly, like any other normal method. Claims are still being verified and functioning normally. But if I call a method directly that has attributes, the attributes are ignored, and I have to provide all the test data manually through the code. Is there some kind of test runner class in XUnit that I can use for this? I am trying to dig their API to no avail.
Why I want to do this will require some explanation, but carrying with me. I write tests against specific interfaces, and not their specific implementations (for example, consider standard collection interfaces). There are many there to check, and I do not want to copy them for each specific artist (maybe dozens). I write tests once, and then pass each concrete implementation of the interface as the first argument of the test, the subject for testing.
But that leaves a problem. XUnit sees the test and wants to run it, but it cannot, because at this level there are no concrete implementations, there is only an interface. Therefore, I want to write tests at a higher level that just update specific implementations, and then call interface tests that go through new topics. I can easily do this for tests that take only one argument, a topic, but for tests in which I use InlineData or MemberData, I would like to reuse the test cases that have already been provided, and just add the topic as the first argument .
source
share