Forum Discussion
The following Groovy script can be added to you TestSuite Setup Script:
// Loop through each test case and all of their test steps within the test suite.
// NOTE: getTestSteps() and getTestCases() return Maps with the name as the key and the actual case/step as the value.
testSuite.getTestCases().each() { teatCaseName, testCase ->
testCase.getTestSteps().each() { testStepName, testStep ->
// Check to see if current step implements the interface Assertable
if (testStep in com.eviware.soapui.model.testsuite.Assertable){
def assertionCount = testStep.getAssertionCount()
if(!assertionCount){
log.warn('The test step "' + testStep.getName() + '" in the test case "' + testCase.getName() + '" does not have any assertions!')
}
}
}
}
This will loop through all of your test cases and their test steps before the test suite is run, logging a warning message when it finds one without an assertion. This could easily be tweaked to do what you want.
Note: If you add this to your test suite Setup Script it will run every time you run your test suite, you will have to decide if this has a significant performance impact or not.
Edit: I see that conversation has occured as I was typing out a reply, and now there is a bit more information. you should be able to move the above script to the Project startup script, and then an add a test suite loop.
1. user can just run this script even if it is in the setup script without running the test suite. once got the details, just comment it out.
2. otherwise, if you do not wish to edit the script / comment / uncomment, then just put it inside a condition say if loop based on a suite level property RUN_SHOW_MISSING_ASSERTIONS with value false.
For eg: if RUN_SHOW_MISSING_ASSERTIONS is true, then only run the Radford provided code
if ( 'true' == context.expand('${#TestSuite#RUN_SHOW_MISSING_ASSERTIONS}')) {
//the code goes here.
}
Just change the property RUN_SHOW_MISSING_ASSERTIONS value to change the execution behaviour without impacting the performance.