Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you get the iteration / line number from TestContext in data driven tests?

I've implemented a data driven test using MsTest framework.

I was wondering if there was a way to get the iteration / line number of the current test code from the TestContext object?

As far as I can see, the only property relevant to DDT is DataRow that enables getting info for the current iteration from the data source, but I don't see any property that gives me what I need.

like image 606
user1039580 Avatar asked Feb 26 '12 16:02

user1039580


People also ask

What attribute marks a test method as being data driven?

When a test is marked as data theory, the data fed into it from the data source is directly mapped to the parameters of the test method.

What is TestContext C#?

Used to store information that is provided to unit tests.


1 Answers

Try this:

int currentIteration = TestContext.DataRow.Table.Rows.IndexOf(TestContext.DataRow);
like image 114
chaliasos Avatar answered Oct 10 '22 19:10

chaliasos