我的单元测试类中有 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 通过。测试名称:sortTest2。
我做的另外两个测试发生了什么?