访问测试用例和测试套件的上下文

有的时候,必须将正在执行的录制或者代码中的一些内容传到接下来要执行的模块中去。代码示例演示了如何使用在测试用例data binding对话框中指定的参数“DialogText”来在测试用例中传递数据。

C#

// —————– Code Block used by Code Module A —————–

// Click ‘Save’ button to open ‘SaveDialog’
repo.MyApp.Buttons.ButtonSave.Click();
// Read text message shown with ‘SaveDialog’
// and assign it to the variable ‘varDialogTextA’ bound to a test case parameter
varDialogTextA = repo.SaveDialog.TextMessage.TextValue;

 

// ——– Code Block used by User Code Action of recording B ——–

// Read value of module variable ‘varDialogTextB’ in other code module
// or recording module using a user code action
Report.Info(varDialogTextB);

// Get the current data context and log
// the current row index of a data driven run
Report.Info(TestCase.Current.DataContext.CurrentRow.ToString());

 

VB.NET

‘ —————– Code Block used by Code Module A —————–

‘ Click ‘Save’ button to open ‘SaveDialog’
repo.MyApp.Buttons.ButtonSave.Click()
‘ Read text message shown with ‘SaveDialog’
‘ and assign it to the variable ‘varDialogTextA’ bound to a test case parameter
varDialogTextA = repo.SaveDialog.TextMessage.TextValue

‘ ——– Code Block used by User Code Action of recording B ——–

‘ Read value of module variable ‘varDialogTextB’ in other code module
‘ or recording module using a user code action
Report.Info(varDialogTextB)

‘ Get the current data context and log
‘ the current row index of a data driven run
Report.Info(TestCase.Current.DataContext.CurrentRow.ToString())

Leave a comment

请输入正确的验证码