为什么不能从其他程序集继承测试方法

时间:2022-11-19 10:17:28

WHy is it not possible to inheritance tests from other assemblies to run:

为什么不能从其他程序集继承测试来运行:

namespace TestProject.Base
{
    [TestClass]   
    public abstract class TestBaseClass
    {
        [TestMethod]
        public void BaseTest()
        {
            Assert.IsTrue(false);
        }
    }
}

Test Runner

namespace TestProject.UnitTest
{   
    [TestClass]
    public class UnitTest : TestBaseClass
    {
    }
}

It is ONLY possible to do run the test when the classes are in the SAME assembly WTF!

当类在SAME程序集WTF中时,只能运行测试!

Is it possible to have test inheritance like above with NUnit and be runnable?

是否可以使用NUnit进行上述测试继承并且可以运行?

1 个解决方案

#1


Unfortunately it seems this is a limitation of the MSUnit framework. In the MSDN documentation it states clearly that tests can inherit methods from another test class in the same assembly (see http://msdn.microsoft.com/en-us/library/ms182517.aspx).

不幸的是,这似乎是MSUnit框架的限制。在MSDN文档中,它明确指出测试可以从同一程序集中的另一个测试类继承方法(请参阅http://msdn.microsoft.com/en-us/library/ms182517.aspx)。

Probably the cause for this is the way MSUnit discovers tests and so far it seems there is no workaround (other than having a copy of the test files in the project).

可能原因是MSUnit发现测试的方式,到目前为止似乎没有解决方法(除了在项目中有一个测试文件的副本)。

#1


Unfortunately it seems this is a limitation of the MSUnit framework. In the MSDN documentation it states clearly that tests can inherit methods from another test class in the same assembly (see http://msdn.microsoft.com/en-us/library/ms182517.aspx).

不幸的是,这似乎是MSUnit框架的限制。在MSDN文档中,它明确指出测试可以从同一程序集中的另一个测试类继承方法(请参阅http://msdn.microsoft.com/en-us/library/ms182517.aspx)。

Probably the cause for this is the way MSUnit discovers tests and so far it seems there is no workaround (other than having a copy of the test files in the project).

可能原因是MSUnit发现测试的方式,到目前为止似乎没有解决方法(除了在项目中有一个测试文件的副本)。