MS Test – define DataRows in separate class

I am working on some legacy code project and I am using MS Test 1.3 for unit testing. I use [DataRow] to pass parameters to my tests, but the problem is that some of my tests have 10-20 [DataRow]s. Is there a way to have them in separate class and pass it like this to unit test?

I think xUnit have something like this (I think it is called a fixture, but not sure if I remember correctly), but I have to stick to MS Test 1.3

Add Comment
1 Answer(s)

You can use the [DynamicData] attribute to achieve this. It accepts non constant values or complex objects to pass parameters to the target tests.

Another option is to use custom datasource. Refer to https://docs.microsoft.com/en-us/dotnet/api/microsoft.visualstudio.testtools.unittesting.itestdatasource?view=mstest-net-1.2.0 for more information.

Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.