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

前端 未结 3 1150
一整个雨季
一整个雨季 2021-02-13 12:39

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 Test

3条回答
  •  [愿得一人]
    2021-02-13 13:14

    private readonly PropertyInfo _rowIdProp = typeof(System.Data.DataRow).GetProperty("rowID", BindingFlags.NonPublic | BindingFlags.GetProperty | BindingFlags.Instance);
    
    ..
    
    // No datarow means only one iteraton
    
    var currentIteration = DataRow == null ? 1 : (Int64)_rowIdProp.GetValue(DataRow, null);
    

提交回复
热议问题