If we have a very large number of tests in our project, and if you want to calculate the number of test suites/ test cases out of it, simply use the below script as a Groovy Script Test Step in your SoapUI.
def totalTestSuiteCount = 0; def enabledTestSuiteCount = 0; def disabledTestSuiteCount = 0; totalTestSuiteCount = testRunner.testCase.testSuite.project.getTestSuiteCount(); for(i = 0; i < totalTestSuiteCount; i++) { flag = testRunner.testCase.testSuite.project.getTestSuiteAt(i).isDisabled(); if(!flag) enabledTestSuiteCount = enabledTestSuiteCount + 1; else disabledTestSuiteCount = disabledTestSuiteCount + 1; } log.info "Total Test Suite Count : " + totalTestSuiteCount; log.info "Total Enabled/Active Test Suite Count : " + enabledTestSuiteCount; log.info "Total Disabled/Reusable Test Suite Count : " + disabledTestSuiteCount; def totalTestCaseCount = 0; def enabledTestCaseCount = 0; def disabledTestCaseCount = 0; for(i = 0; i < totalTestSuiteCount; i++) { flag = testRunner.testCase.testSuite.project.getTestSuiteAt(i).isDisabled(); if(!flag) { totalTestCaseCount = totalTestCaseCount + testRunner.testCase.testSuite.project.getTestSuiteAt(i).getTestCaseCount(); } } for(i = 0; i < totalTestSuiteCount; i++) { flag = testRunner.testCase.testSuite.project.getTestSuiteAt(i).isDisabled(); if(!flag) { tccount = testRunner.testCase.testSuite.project.getTestSuiteAt(i).getTestCaseCount(); for(j = 0; j < tccount; j++) { tcflag = testRunner.testCase.testSuite.project.getTestSuiteAt(i).getTestCaseAt(j).isDisabled(); if(!tcflag) enabledTestCaseCount = enabledTestCaseCount + 1; else disabledTestCaseCount = disabledTestCaseCount + 1; } } } log.info "Total Test Case Count : " + totalTestCaseCount; log.info "Total Enabled/Active Test Case Count : " + enabledTestCaseCount; log.info "Total Disabled/Reusable Test Case Count : " + disabledTestCaseCount;
I am here under an impression that, we should exclude the disabled test suites/cases from the count.
Because, in general we used to disable the test suite/case which is not in a proper working condition or if it is acting as a reusable library.
In my case, I have the habit of creating the reusable components/libraries as a test suite/test case and finally I will disable them to exclude those things from normal execution flow.
So I thought, those things should be omitted from the count when taking the statistics.
The next thing I am looking out for is to cover the datasource/datasource loop count also in number of test cases.
Because we are combining so many similar functional test scenarios into one single test case using datasource/datasource loop test steps.
But finally when getting the count, this will also be calculated as one single test case. I don’t want this to be a single test case. If my data source loop is getting executed 10 times, then my test case count also should be 10 instead of 1.