Forum Discussion
MartinSpamer
12 years agoFrequent Contributor
Jack21Z wrote:
What if I have two or more classes under "module-name", how can I instantiate all the classes on my groovy script
library = testRunner.testCase.testSuite.project.testSuites["Library"]
module = library.testCases["module-name"].testSteps["Example"]
module2 = library.testCases["module-name"].testSteps["other_class"]
module3 = library.testCases["module-name"].testSteps["other_class2"]
....
module.run(testRunner, context)
module2.run(testRunner, context)
module3.run(testRunner, context)
Or there are other ways like:
library = testRunner.testCase.testSuite.project.testSuites["Library"]
for(int i = 0; i <= [i]number_of_classes[/i]; i++){
library.testCases["module-name"].testSteps[i].run(testRunner, context)
}
I haven't tested them, but both of those approaches should work.
I just prefer to keep them seperate as per the single responsibility principle.
Related Content
- 6 years ago
- 4 years ago
Recent Discussions
- 5 days ago
- 9 days ago