In Nunit one can reuse a test method for multiple cases.
[TestCase(12,3,4)]
[TestCase(12,2,6)]
[TestCase(12,4,3)]
public void DivideTest(int n, int d, int q)
{
Assert.AreEqual( q, n / d );
}
How can I do this in Visual Studio's test framework?
Make more copies of the attribute if you want multiple cases. The data type of the values provided to the TestCase attribute should match with that of the arguments used in the actual test case.
The main difference is the ability of MsTest to execute in parallel at the method level. Also, the tight integration of MsTest with Visual Studio provides advantages in both speed and robustness when compared to NUnit. As a result, I recommend MsTest.
NUnit is a unit testing framework for . NET languages, and Moq is the most popular mocking framework for . NET. I assume the reader is familiar with C# projects, Visual Studio IDE, and the Nuget package manager for managing dependencies.
The advantages of using Moq is, we can unit test the code successfully without using an external dependency object in the test code. Conclusion: NUnit and Moq are the suitable frameworks for testing the MVC Model layer.
It is not possible out of the box. But for VS 2010 atleast you can write MSTEST Extensions to provide nearly the same feature. Check this blog. But it is not nearly as good as NUnit's TestCase.
Unfortunately, MS Test doesn't support RowTests. However, a workaround can be hacked using the DataSource attribute. There is an example here.
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