Forum Discussion
6 Replies
- RadfordSuper Contributor
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.
- nmraoCommunity Hero
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 codeif ( '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.
- CBylerContributor
Thank you! I appreciate the help :)
- nmraoCommunity HeroA test case does not have any assertions, instead a test step of request type (soap, rest, jdbc, http) supports to have assertions . So, do you want find if at all assertions defined for specific test step? Or looking for specific Assertion Type? Or something else? And what would you like to do once you found there are no assertions? just list the test step name?
- CBylerContributor
Yes, my bad on stating test case, I thought about that after posting.
I want to find all test steps that do not contain an assertion. I would then prefer to have a list of them so I can easily locate them and add the assertion(s).
I hoped there would be a way to do it via reporting at the Project level. But that only tells me totals on number of test cases, assertions, etc.
- smadjiContributor
For a lower level option
Run all your test, expend the tree (right click and select expend all), and see which one of your tests is green or red, if its neither (and stays gray) it has no assertion and needs your attention.
But I love the script option provided in one of the answers and going to save it in my google-keep for future fun