I try to do data binding of my test suite fully dynamically. I managed to do data-binding for individual modules (recordings), but cannot do it for module groups (see solution attached, Ranorex 4.0.3).
I have a test suite with 3 Test cases:
- InitializeData - here I do all the data binding
- TestCase1 and TestCase2 - sample test cases where I use the data
//Sample test cases data. Here: data for 2 test cases: //1 iteration for TestCase1, and 2 iterations for TestCase2 IDictionary<string, IList<IDictionary<string, string>>> data = new Dictionary<string, IList<IDictionary<string, string>>>(); data.Add("TestCase1", new System.Collections.Generic.List<IDictionary<string, string>>(){ new Dictionary<string, string>(){{"var1", "VARIABLE 11-1"}, {"var2", "VARIABLE 11-2"}} }); data.Add("TestCase2", new System.Collections.Generic.List<IDictionary<string, string>>(){ new Dictionary<string, string>(){{"var1", "VARIABLE 21-1"}, {"var2", "VARIABLE 21-2"}}, new Dictionary<string, string>(){{"var1", "VARIABLE 22-1"}, {"var2", "VARIABLE 22-2"}} });Then I create a CustomConnector (I took a sample from topic " http://www.ranorex.com/forum/how-to-int ... t3511.html ") and do data-binding:
IList<TestCase> tcases = TestSuite.Current.SelectedRunConfig.GetActiveTestCases(); foreach(TestCase tc in tcases){ ... //Do data binding for all modules of the test case IList<TestSuiteModule> modules = tc.AllModules; foreach(TestSuiteModule module in modules){ ColumnCollection columns = dataCache.Columns; BindVariables(tc, module, columns); } }Data binding is done using this function:
void BindVariables(TestCase tc, TestSuiteModule module, ColumnCollection columns){ Report.Warn("Doing data binding for module: " + module.Name + " : " + module.Type); //bind variables dor all column names of the test case's data connector foreach(Ranorex.Core.Data.Column column in columns){ module.AddDataBinding(new ModuleVarItem(column.Name, Guid.NewGuid().ToString(), module.Name, ""), new DataConnectorBindingInfo(column.Name, tc.Id, tc.DataContext)); } }I also tried to do data binding not for the module group as a whole by for individual modules, but moduleGroup.AllModules is always empty.
//if the module is TestSuiteModule, do data binding for it //if the module is TestSuiteModuleGroup, do data binding for all its submodules if (module.GetType() == typeof(TestSuiteModule)) { BindVariables(tc, module, columns); } else if (module.GetType() == typeof(TestSuiteModuleGroup)) { TestSuiteModuleGroup moduleGroup = (TestSuiteModuleGroup)module; //PROBLEM: moduleGroup.AllModules is always empty! IList<TestSuiteModule> modulesInGroup = moduleGroup.AllModules; foreach(TestSuiteModule moduleInGroup in modulesInGroup){ BindVariables(tc, moduleInGroup, columns); } }Current situation: Data binding for modules works correctly. Data binding for module groups does not. I always get warning in the report: "The following module group variables are not bound to a data column: var1, var2"
- Could you please take a look at the code and advise me where the problem with module groups is?
- Could you please also tell me why although data binding for individual modules works, I still get warnings: "The following module variables are not bound to a data column: var1, var2" (variables values are then passed correctly)