Is defining TestMethod's in test base classes not supported by MsTest?

前端 未结 3 1613
南旧
南旧 2021-02-11 22:31

This question concerns a general unit test technique with a potentially very useful wide range of applicable scenarios. But it is easier to understand with an example to illustr

3条回答
  •  梦如初夏
    2021-02-11 22:59

    Out of the box, it looks like unit test inheritance only works if the base test class is in the same assembly as the derived classes. For me, this usually defeats the purpose of having the base class. I, too, wonder why there isn't more posted about this on blogs, and if I might be missing something.

    You might be able to work around the problem by linking the base class into every project where you want to use it. Maybe mark it as internal so the multiple copies don't interfere with each other.

    There's also the TestClassExtensionAttribute that you can extend to hook into the test execution engine. I tried using it to reflect over the test classes and load the base class's tests, but a lot of the classes are undocumented, and I couldn't get it to work.

提交回复
热议问题