Visual Studio data-driven tests
I'm using a TextContext property to access the current row in an Excel file. The test is repeated for all rows. Is it possible to access all rows in a single step? Rows are related, hence for me one sheet should be a complete run.
Edit: I add some code as requested:
int result = this.TextContext.Rows[0]["GlobalResult"];
foreach(var row in this.TestContext.Rows.Skip(1))
{
componentToTest.Eval(Convert.ToInt32(row["A"]), Convert.ToInt32(row["B"]));
}
Assert.AreEqual(result, componentToTest.Result);
And the file would appear like this:
GlobalResult,开发者_Python百科 A, B 100, null, null null, 1, 5 null, 3, 6 ... and so on
Thank you very much
Instead of using data driven tests, why don't you just read the Excel file and iterate through the rows? Take a look at this SO question on how to read an Excel file's contents. You can then iterate through the rows in a test without having to use MSTest data driven attributes.
Cheers. Jas.
精彩评论