繁体   English   中英

Visual Studio不会在测试类中运行所有单元测试

[英]Visual Studio does not run all the unit tests in a test class

我的单元测试类中有3个测试方法,但Visual Studio只运行第二个测试,忽略其他测试

这些是3种测试方法:

[TestClass()]
public class InsertionSortTest
{

    [TestMethod()]
    public void sortTest()
    {
        InsertionSort target = new InsertionSort(); // TODO: Initialize to an appropriate value
        int[] n = new int[] { 2, 1, 4 };
        int[] nExpected = new int[] { 1, 2, 4 };
        target.sort(ref n);
        CollectionAssert.AreEqual(nExpected, n);

    }

    [TestMethod()]
    public void sortTest2()
    {
        InsertionSort target = new InsertionSort(); // TODO: Initialize to an appropriate value
        int[] n = new int[] { 1, 2 };
        int[] nExpected = new int[] { 1, 2 };
        target.sort(ref n);
        CollectionAssert.AreEqual(nExpected, n);

    }

    [TestMethod()]
    public void sortTest3()
    {
        InsertionSort target = new InsertionSort(); // TODO: Initialize to an appropriate value
        int[] n = new int[] { 1, 2 };
        int[] nExpected = new int[] { 1, 2 };
        target.sort(ref n);
        CollectionAssert.AreEqual(nExpected, n);

    }
}

所以当我运行测试时,只执行sortTest2? 我期待3个结果。 我结果1/1通过了。 TestName:sortTest2。

我做的其他两个测试怎么了?

我注意到测试运行完成后测试显示为“未运行”。 原来这些测试从未完成,因为StackOverflowException被抛向中途。

吉利布,是的,我认为你在哪里。 重新启动Visual Studio修复了问题。

我不止一次咬过我的东西是没有检查测试项目是否在解决方案配置中构建。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM