I have a test method that tests the ToString() method of a class against known good outputs.
/// <summary>
///A test for ToString
///</summary>
[TestMethod()]
public void ToStringTest()
{
string input = System.IO.File.ReadAllText(@"c:\temp\input2005.txt");
MyClass target = new MyClass(input);
string expected = System.IO.File.ReadAllText(@"c:\temp\output2005.txt");
string actual;
actual = target.ToString();
Assert.AreEqual(expected, actual);
}
The method works great, but I already have several pairs of input/output files. Experience tells me that I don't want to write a separate test method for each pair. I also don't want to loop through each pair of files because I won't know which pair caused the test to fail. What do I do?