You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trying to convert an old NUnit test project to MSTest (while porting a solution to .Net Core). The existing tests all use the same set of about 200 text files across several folders to hold all the test cases. The existing NUnit implementation has a single utility function that reads the contents of each directory and provides the sets of file names as an IEnumerable<string>. Then each test takes a single string parameter to tell it what file has the test case.
I can find no way to replicate this behavior with MSTest (v1.1.11). Any function that takes any parameters throws a TargetParameterCountException with the message "Parameter count mismatch" (probably issue #199 ). Additionally any attempt to use the TestContext.DataRow property won't compile. It seems in previous versions of MSTest the DataRow property only appeared when a reference to the System.Data assembly was added but I can't find a .Net Core equivalent. (System.Data.Common didn't work and nothing else seemed appropriate. The Reverse Package Search didn't find anything that seemed relevant).
How can I get something close to this behavior without coding hundreds of separate test cases?
Thanks!
Steps To Reproduce
[TestClass]publicclassTests{publicTestContextContext{get;set;}publicstaticIEnumerable<string>FolderFileNameIterator(){vartextFileFolder=newDirectoryInfo("Data");foreach(varsampleFileintextFileFolder.GetFiles()){yieldreturnsampleFile.Name;}}[TestMethod,DataSource("FolderFileNameIterator")]publicvoidTest1(stringFileName){// Test code}[TestMethod,DataSource("FolderFileNameIterator")]publicvoidTest2(){varfileName=Context.DataRow[0];// Won't compile// Test code}}
Environment
Test Assembly:
NetCoreApp 1.1
MSTest.TestFramework 1.1.11
MSTest.TestAdapter 1.1.11
Microsoft.NET.Test.Sdk 15.0.0
Assembly Under Test:
Net Standard 1.4
The text was updated successfully, but these errors were encountered:
@bungeemonkee : I believe DynamicData attribute is what you are looking for. Its been added into the 1.2.0-beta version of the Framework/adapter tuple. #169 details this better.
Thanks @AbhitejJohn I'll try this out in a few hours and close this issue if it works. In that case it would seem the real issue is one of documentation.
Description
Trying to convert an old NUnit test project to MSTest (while porting a solution to .Net Core). The existing tests all use the same set of about 200 text files across several folders to hold all the test cases. The existing NUnit implementation has a single utility function that reads the contents of each directory and provides the sets of file names as an
IEnumerable<string>
. Then each test takes a singlestring
parameter to tell it what file has the test case.I can find no way to replicate this behavior with MSTest (v1.1.11). Any function that takes any parameters throws a
TargetParameterCountException
with the message "Parameter count mismatch" (probably issue #199 ). Additionally any attempt to use theTestContext.DataRow
property won't compile. It seems in previous versions of MSTest the DataRow property only appeared when a reference to the System.Data assembly was added but I can't find a .Net Core equivalent. (System.Data.Common didn't work and nothing else seemed appropriate. The Reverse Package Search didn't find anything that seemed relevant).How can I get something close to this behavior without coding hundreds of separate test cases?
Thanks!
Steps To Reproduce
Environment
Test Assembly:
NetCoreApp 1.1
MSTest.TestFramework 1.1.11
MSTest.TestAdapter 1.1.11
Microsoft.NET.Test.Sdk 15.0.0
Assembly Under Test:
Net Standard 1.4
The text was updated successfully, but these errors were encountered: