从通用基础测试继承类MSTest的被忽略

问题描述:

在创造MSTest的通用基础测试类,并从它继承,我无法运行所有的继承类的测试。

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.

BaseDependencyPropertyFactoryTest 的是位于 Whathecode.PresentationFramework.Tests 的组装。它是通用的基类。 ( BaseDependencyPropertyFactoryTest< TTestClass> 的)

BaseDependencyPropertyFactoryTest is located in the Whathecode.PresentationFramework.Tests assembly. It is the generic base class. (BaseDependencyPropertyFactoryTest<TTestClass>)

这两个组件进行测试,从这个基类继承,所谓的 DependencyPropertyFactoryTest 的。所有继承类确实是通过一个特定的类型参数。

Both assemblies have a test inheriting from this base class, called DependencyPropertyFactoryTest. All the inherited class does is passing a specific type argument.

[TestClass]
public class DependencyPropertyFactoryTest
    : BaseDependencyPropertyFactoryTest<ASpecificClass>
{
}



只有继承测试位于同一装配为一体的基类似乎运行。在继承的测试中的 Whathecode.PresentationFramework.Aspects.Tests 的装配似乎被完全忽略。

Only the inheriting test located in the same assembly as the base class seems to run. The inherited test in the Whathecode.PresentationFramework.Aspects.Tests assembly seems to be ignored entirely.

我在做什么错了?当需要时,我可以上传所有所需的源代码,但您需要PostSharp的方面装配。

What am I doing wrong? When desired I could upload all the required source code, but you will need PostSharp for the aspects assembly.

作为测试,我尝试添加一个测试,在各方面装配继承测试类,它调用的基础测试类的所有测试。

As a test, I tried adding a test to the inherited test class in the aspects assembly, which calls all the tests in the base test class.

[TestMethod]
public void AllBaseTests()
{
    ClrGetterSetterTest();
    DependencyPropertyGetterSetterTest();
}

这给出了以下的结果。奇怪的是这个测试被执行!现在这可能工作作为一种至少运行它们,但我当然不希望每次我加在基类中额外的测试时间来编辑这个测试。

This gives the following result. Strangely enough this test is executed! For now this might work as a way to at least run them, but of course I don't want to edit this test each time I add extra tests in the base class.

为什么这些基地的测试跳过,为什么显示中止?

Why are those base tests skipped, and why the indication 'Aborted'?

这样做的原因没有泛型做,但与试验在不同的组件之中。

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

一个Microsoft连接的建议能说明问题:的Visual Studio的测试(MSTest的)和缺乏继承的支持驻留在基类不同的组件。它被标记为固定,但似乎并没有被固定在Visual Studio 2010还没有,也许它仍然需要释放?

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.