Reputation: 427
I'm looking for a way to get all the test cases with belonging test steps in SoapUI Pro.
I've managed to get all the test steps under one test case (Groovy in Setup Script)
def projectName= testRunner.testCase.testSuite.project.getName()
def testcaseName = testRunner.getTestCase().getName()
File myTestFile = new File("C:/temp/" + projectName + ".txt")
myTestFile .withWriterAppend{ out ->
out.println("TestCase: " + testcaseName)
testRunner.testCase.getTestStepList().each(){
out.println("TestStep: " + it.getName())
}
}
How can I get all test cases and test steps?
Upvotes: 2
Views: 1920
Reputation: 23
I can't comment (<50 reputation) or Edit (edit queue is full) on ou_ryperd's answer, but I put here a little change to anyone else that will use his code.
If the code is executed within a case context, the 2nd for called always the current TestSuite. Call the TestSuite from the 1st for instead, this way:
for ( testSuite in testRunner.testCase.testSuite.project.getTestSuiteList() ) {
for ( testCase in testSuite.getTestCaseList() ) {
for ( testStep in testCase.getTestStepList() ) {
log.info "${testSuite.getName()} : ${testCase.getName()} : ${testStep.getName()} is a test step of type: ${testStep.getClass().toString().tokenize('.')[-1]}"
}
}
}
All credits to ou_ryperd.
Upvotes: 2
Reputation: 2131
This will help you:
for ( testSuite in testRunner.testCase.testSuite.project.getTestSuiteList() ) {
for ( testCase in testRunner.testCase.testSuite.getTestCaseList() ) {
for ( testStep in testCase.getTestStepList() ) {
log.info "${testSuite.getName()} : ${testCase.getName()} : ${testStep.getName()} is a test step of type: ${testStep.getClass().toString().tokenize('.')[-1]}"
}
}
}
Upvotes: 3