My goal is to have โnestedโ data in each of my unit test Iterations. I want to do this so that I have a dataset to call, as well as a list of actions (described by strings) that are then interpreted and executed in my tests. Currently, I have tests running in VS2013 using Test Explorer using incorrectly nested data (e.g. groups of data / action items).
For example, my data might be:
<TestData> <Iteration> <Data> <LoginName>admin</LoginName> <Password>admin</Password> </Data> <Actions> <Action>EnterText_LoginName</Action> <Action>EnterText_Password</Action> <Action>ClickButton_Login</Action> </Actions> </Iteration> </TestData>
I would like to access the elements in the Data according to the usual non-nested test ( dataElements["element"] ), however I would like to have Actions elements in the list. I tried the following without success:
var data = TestContext.DataRow.GetChildRows("Iteration_Data"); var actions = TestContext.DataRow.GetChildRows("Iteration_Actions");
GetChildRows seems like the right method, but I canโt see any data in the returned object that looks like my XML elements - I get only 1 DataRow object that has an ItemArray of 3 values โโ(0, {}, 0). How to get a list of my Action elements so that I can access the text:
- "EnterText_LoginName"
- "EnterText_Password"
- "ClickButton_Login"
source share