I have 3 test methods in my unit test class, but Visual Studio only runs the second test, ignoring the others
These are the 3 test methods:
[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);
}
}
So when I run the test only sortTest2 is executed? I am expecting 3 results from this. I am getting Results 1/1 passed. TestName: sortTest2.
What happened with the other two tests I made?
gillyb, yeah, you where right I think. Re-starting Visual Studio fixed the problem.
I have noticed tests being shown as "not run" after test run completed. Turned out these tests were never completed due to a StackOverflowException being thrown mid way.
Something that has bitten me more than once with this is that the test project was not checked to be built in the solution configuration.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With