I have test methods decorated with a DataSource attribute like:
[DataSource(PROVIDER_INVARIANT_NAME, CONNECTION_STRING,
"Test Case#", DataAccessMethod.Sequential),
TestMethod]
with the test case number in MTM replacing “Test Case#”. I’m trying to get that number within the unit test but TestContext.DataRow.Table.TableName is always “Table1”. Can anyone tell me how to get the real value?
Unless I’m wrong, the “TestCase#” cannot be replaced by MTM, so propably you have manually added it in all your
DataSourceattributes.This value is
constant. Why don’t you add a constant variable to yourTestClassand then use it on both theDataSourceAttributeand yourTestMethod?EDIT
You can also access the
DataSourceAttributedirectly: