run testcase from different testsuite from CLI
- 7 years ago
hello bpistole,
here is sample code on how I call another testcase in a different suite. I just ran it from cli and it works from there. I am setting a property in the test suite i am calling with the testcase name that invoked it. It might just be some small differences that are causing the issue that I cannot really say are the reason for your issue. Anyway, working sample follows:
//
// Invoke a global test case that will invoke a compare process based on the given test case name being sent to it.
//
def invokeTestSuiteName = 'Common Code';
def invokeTestCaseName = 'Global Processing For DDL';
def properties = new com.eviware.soapui.support.types.StringToObjectMap();
def async = false;
testRunner.testCase.testSuite.project.getTestSuiteByName(invokeTestSuiteName).setPropertyValue(invokeTestSuiteName.replaceAll('\\s', '') + "testCaseName", testRunner.testCase.name);
def result = testRunner.testCase.testSuite.project.getTestSuiteByName(invokeTestSuiteName).getTestCaseByName(invokeTestCaseName).run (properties, async);
if (result.status.toString() == 'FINISHED' || result.status.toString() == 'PASS') {
// do nothing
}
else {
assert false, "There are differences between what business has requested and the actual database implementation. See 'difference' output file";
};log.info 'Test Step "' + testRunner.runContext.currentStep.name + '" done...';
.
.
.
From within the called testcase I grab the testcase name that invoked it...
def testSuiteReference = testRunner.testCase.testSuite; // log.info "testSuiteReference is:" + testSuiteReference;
def testSuiteName = testSuiteReference.getName(); // log.info "testSuiteName is:" + testSuiteName;
def calledFromTestCaseName = testRunner.testCase.testSuite.getPropertyValue( testSuiteName.replaceAll('\\s', '') + "testCaseName"); //log.info 'calledFromTestCaseName=' + calledFromTestCaseName;
def tcNameList = calledFromTestCaseName.split('"').toList(); //log.info 'tcNameList=' + tcNameList;
def testableName = tcNameList[1].toLowerCase(); //log.info 'testableName=' + testableName;
testableName = testableName.replaceAll(' ', '');
log.info '########################### testableName=' + testableName;