Forum Discussion

alivera's avatar
alivera
New Contributor
8 years ago

SoapUI :: Get Test Step Count for all test cases in a project

Hi, my name is Ali, I'm new to the forums but been using SoapUI/ReadyAPI for over a year now. I'm gonna jump straight to my question. I need help with a script to get a count of all the test steps in a projects across all test suites and test cases. I did a search but found the groovy script for the test step count for only one test case. I have over 100 test cases nested in over a dozen test suites so it's not ideal to individually drill down into each test case. The following code gets the count test steps in 1 test case:

def totalSteps = testRunner.testCase.getTestStepCount()

 for(i=0; i<totalSteps; i++)
 {
  def flag = testRunner.testCase.getTestStepAt(i).disabled
  if(flag == "false")
  {
   counter = counter + 1
  }
 }
 log.info "Total Test Step: " + totalSteps

 

  • Here's something I have that is similar to what you want. It'll loop through all test suites in a project, all test cases in a suite, and count all the test steps in each test case.

     

    def testStepCount = 0;
    def project = context.testCase.testSuite.project;
    
    for (int i = 0; i < project.getTestSuiteCount(); i++)
    {
    	def testSuite = project.getTestSuiteAt(i);
    	def testCaseCount = testSuite.getTestCaseCount();
    	for (int j = 0; j < testCaseCount; j++)
    	{
    		def testCase = testSuite.getTestCaseAt(j);
    		testStepCount = testStepCount + testCase.getTestStepCount();
    	}
    }
    
    log.info("Total Test Steps: " + testStepCount.toString());
  • groovyguy's avatar
    groovyguy
    Community Hero

    Here's something I have that is similar to what you want. It'll loop through all test suites in a project, all test cases in a suite, and count all the test steps in each test case.

     

    def testStepCount = 0;
    def project = context.testCase.testSuite.project;
    
    for (int i = 0; i < project.getTestSuiteCount(); i++)
    {
    	def testSuite = project.getTestSuiteAt(i);
    	def testCaseCount = testSuite.getTestCaseCount();
    	for (int j = 0; j < testCaseCount; j++)
    	{
    		def testCase = testSuite.getTestCaseAt(j);
    		testStepCount = testStepCount + testCase.getTestStepCount();
    	}
    }
    
    log.info("Total Test Steps: " + testStepCount.toString());