我正在尝试在Visual Studio中使用C#遍历所有测试操作,TFS的预期结果。
为采取行动,我编写了以下代码。请让我知道是否有人想遍历整个过程。
代码:
#region To get testSteps for every Test Case (Shared and Regular test steps)
foreach (ITestPlan tp in plans)
{
if (tp.RootSuite != null && tp.RootSuite.Entries.Count > 0)
{
foreach (ITestSuiteEntry _iTestSuiteEntry in tp.RootSuite.Entries)
{
foreach (ITestSuiteEntry tstCases in _iTestSuiteEntry.TestSuite.TestCases)
{
#region for test action
foreach (ITestAction tstAction in tstCases.TestCase.Actions)
{
ISharedStep txtSharedStep = null;
ISharedStepReference txtStepRef = tstAction as ISharedStepReference;
if (txtStepRef != null)
{
txtSharedStep = txtStepRef.FindSharedStep();
foreach (ITestAction tstSharedAction in txtSharedStep.Actions)
{
//Shared Teststep
ITestStep tstSharedTestStep = tstSharedAction as ITestStep;
}
}
else
{
//Regular TestStep
ITestStep tstStep = tstAction as ITestStep;
}
}
#endregion//
}
}
}
}
#endregion