Forum Discussion

linkeshkanna's avatar
linkeshkanna
Occasional Contributor
9 years ago

RE: SoapUI NG Pro Count No. Of Test Cases

Hello,

 

I just want to know how to count the total number of test cases inside my Project. I have certain condition to apply on this.

1. The disabled/reusable TestSuites/Test Cases Should be omitted from this count.

2. If any of the Test Cases involves with DataSource/DataSourceLoop Test Steps, then I need to count the total number of rows inside the DataSource as Test Case Count. I dont want to count the entire Datasource/loop as a single test case.

 

I have the following script to achieve the Task 1. But want to know how to achieve the Task 2.

 

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;

 

3 Replies

  • Tylhadras's avatar
    Tylhadras
    SmartBear Alumni (Retired)

    Hello linkeshkanna.

     

    Let's say you have a List of Test Steps you can then:

     

    import com.eviware.soapui.impl.wsdl.teststeps.WsdlDataSourceTestStep
    import com.eviware.soapui.impl.wsdl.teststeps.WsdlDataSourceLoopTestStep
    
    for (testStep in listOfTestSteps) {
        if (testStep instanceof WsdlDataSourceTestStep) {
            def rowCount = testStep.rowCount
            log.info("This Test Step has : " + rowCount + " rows.")
        } else if (testStep instanceof WsdlDataSourceLoopTestStep) {
            def dataSource = yourTestCase.getTestStepByName(testStep.dataSourceStep)
            def rowCount = dataSource.rowCount
            log.info("This Test Step has : " + rowCount + " rows.")
        }
    }

    This example shows you how to get the rowcount from Data Source Test Steps. But you'll definetely want to tweak it to fit what you are doing. Good luck!

     

    Regards

    Gustav Lundström

    • linkeshkanna's avatar
      linkeshkanna
      Occasional Contributor

      Hello Tylhadras,

      Thanks for your reply. I will give this a try and let you know the outcome.

       

      Thanks,

      linkeshkanna

    • linkeshkanna's avatar
      linkeshkanna
      Occasional Contributor

      Hi,

       

      Most of my DataSource use external files like Excel, text and JSON files.

       

      Is it possible to get the row count/test count from these external files from SoapUI?

       

      Thanks,

      Linkesh