I know that MSTest doesn't support RowTest
and similar tests.
What do MSTests
users do? How is it possible to live without RowTest
support?
I've seen DataDriven
test features but sounds like too much overhead, is there any 3rd party patch or tool which allow me to do RowTest
similar tests in MSTest
?
I have solved this issue by generating test class code with different number of generated test methods. You just have to download 2 files and include them into your project.
Then subclass a class with required number of rows in your test code and implement 2 abstract methods:
More details:
https://github.com/dzhariy/mstest-rows
We have added in support for DataRow in VS2012 Update1. See this blog for a breif introduction
Edit: Want to highlight that this feature is currently limited to Windows store apps.
On my team that is locked into using the MS Test framework, we developed a technique that relies only on Anonymous Types to hold an array of test data, and LINQ to loop through and test each row. It requires no additional classes or frameworks, and tends to be fairly easy to read and understand. It's also much easier to implement than the data-driven tests using external files or a connected database.
For example, say you have an extension method like this:
You could use and array of Anonymous Types combined to LINQ to write a tests like this:
When using this technique it's helpful to use a formatted message that includes the input data in the Assert to help you identify which row causes the test to fail.
I've blogged about this solution with more background and detail at AgileCoder.net.
I know this is a late answer but hopefully it helps others out.
I looked everywhere for an elegant solution and ended up writing one myself. We use it in over 20 projects with thousands of unit tests and hundreds of thousands of iterations. Never once missed a beat.
https://github.com/Thwaitesy/MSTestHacks
1) Install the NuGet package.
2) Inherit your test class from TestBase
3) Create a Property, Field or Method, that returns IEnumerable
4) Add the MSTest DataSource attribute to your test method, pointing back to the IEnumerable name above. This needs to be fully qualified.
End Result: 3 iterations just like the normal DataSource :)
Similar to DaTest(not updated since 2008) solution using PostSharp is described in blog http://blog.drorhelper.com/2011/09/enabling-parameterized-tests-in-mstest.html