Inherited test class from generic base is ignored in MSTest

后端 未结 4 712
死守一世寂寞
死守一世寂寞 2021-01-04 00:14

When creating a generic base test class in MSTest, and inheriting from it, I\'m unable to run the tests of all the inheriting classes.

4条回答
  •  庸人自扰
    2021-01-04 01:02

    The cause of this doesn't have to do with generics, but with the tests being in different assemblies.

    A Microsoft Connect suggestion describes the problem: "Visual Studio Test (MSTest) and lack of Inheritance support for base classes that resides in different assemblies." It is marked as 'fixed', but doesn't seem to be fixed in Visual Studio 2010 yet, perhaps it still needs to be released?

    There is one interesting workaround to this problem:

    You can work around this problem by compiling the source file containing the base class into all test projects that wish to derive from that base class. Add the item as a "link" so that you don't end up with multiple copies of the source file for the base class.

    This worked for me, and I don't find the workaround too ugly.

提交回复
热议问题