Testing / Ranorex Interview questions
How do you implement data-driven testing using Ranorex?
Implementing data-driven testing means binding a test case to an external data source and letting Ranorex run that test case once per row automatically.
- Add a data connector for the source - a CSV file, an Excel sheet, or a database via an ADO.NET connection - to the Test Suite.
- Bind the target test case's DataSource property to that connector.
- Reference each column as a
$variableinside the test case's recording or code modules, in place of hardcoded values. - Run the test case: Ranorex iterates the data source and executes the case once per row, substituting that row's values each time.
// Code module reading a bound data row [TestModule("A2C1...")] public class LoginWithData : ITestModule { public void Run() { string user = testCase.Activity.DataContext.CurrentRow["Username"].ToString(); string pass = testCase.Activity.DataContext.CurrentRow["Password"].ToString(); repo.LoginForm.UsernameInfo.CreateAdapter<Text>(true).PressKeys(user); repo.LoginForm.PasswordInfo.CreateAdapter<Text>(true).PressKeys(pass); } }
Every iteration gets its own entry in the Report, so a failure on row 7 of 20 is visible individually rather than being buried inside one combined result for the whole data set.
More Related questions...