I have upgraded from Visual Studio 2010 to Visual Studio 2012.
In my unit test project, I have a [ClassInitialize] method which generates a CSV file which I then fee
MSTestHacks might help.
It allows an IEnumberable
on your test class to be used as the DataSource
for your TestMethod
.
From the website:
You MUST inherit your test class from TestBase
[TestClass]
public class UnitTest1 : TestBase
{ }
Create a Property, Field or Method, that returns an IEnumerable
[TestClass]
public class UnitTest1 : TestBase
{
private IEnumerable<int> Stuff
{
get
{
//This could do anything, fetch a dynamic list from anywhere....
return new List<int> { 1, 2, 3 };
}
}
}
Add the DataSource
attribute to your test method, pointing back to the IEnumerable
name created earlier. This needs to be fully qualified.
[TestMethod]
[DataSource("Namespace.UnitTest1.Stuff")]
public void TestMethod1()
{
var number = this.TestContext.GetRuntimeDataSourceObject<int>();
Assert.IsNotNull(number);
}