17 years ago
Calling another TestCase from a TestCase Using Groovy
I need to call another TestCase from within another Parent TestCase based on a Data Source Property that I have configured.
The following is some basic code that I am playing with but I am having trouble getting context of another TestSuite and then calling a TestCase within it.
Can someone please help?
//**************************************************************
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context );
// Get the DataSource Step and the TEST_NUMBER
def tsDataSource = testRunner.testCase.getTestStepByName("Test Cases DataSource");
testNumber = tsDataSource.getProperty("TEST_NUMBER").value;
// Because each row in the Excel file does not contain actual data check to make sure we have valid data to process
if (testNumber != ""){
// Write to the log
log.info "************************ Valid Test Case: " + testNumber + "************************";
// Get the name of the Configuration TestCase......
configurationData = tsDataSource.getProperty("CONFIGURATION_DATA").value;
// Check to see if the TestCase has any Network Configuration required......
if (configurationData != ""){
// The TestCase requires some configuration so we need to call the corresponding configuration TeseCase.......
log.info "**************************** Setting Up Network with: " + configurationData + "************************";
//context.getTestCase(configurationData);
// Get the Network Configuration TestSuite by name........
def tsConfiguration = context.testSuite.getTestCaseByName( "NRM Test Cases Setup" );
// Use the TestCase name from the Excel data....
def tcConfiguration = tsConfiguration.getTestCaseByName(configurationData);
// Now run the TestCase and configure the Network...
tcConfiguration.run;
}else
{
log.info "**************************** No Network Setup Required ************************";
}
}else
{
// The row contained no data so skip this row.......
testRunner.gotoStepByName( "DataSource Loop" );
}
Thanks,
Steve
The following is some basic code that I am playing with but I am having trouble getting context of another TestSuite and then calling a TestCase within it.
Can someone please help?
//**************************************************************
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context );
// Get the DataSource Step and the TEST_NUMBER
def tsDataSource = testRunner.testCase.getTestStepByName("Test Cases DataSource");
testNumber = tsDataSource.getProperty("TEST_NUMBER").value;
// Because each row in the Excel file does not contain actual data check to make sure we have valid data to process
if (testNumber != ""){
// Write to the log
log.info "************************ Valid Test Case: " + testNumber + "************************";
// Get the name of the Configuration TestCase......
configurationData = tsDataSource.getProperty("CONFIGURATION_DATA").value;
// Check to see if the TestCase has any Network Configuration required......
if (configurationData != ""){
// The TestCase requires some configuration so we need to call the corresponding configuration TeseCase.......
log.info "**************************** Setting Up Network with: " + configurationData + "************************";
//context.getTestCase(configurationData);
// Get the Network Configuration TestSuite by name........
def tsConfiguration = context.testSuite.getTestCaseByName( "NRM Test Cases Setup" );
// Use the TestCase name from the Excel data....
def tcConfiguration = tsConfiguration.getTestCaseByName(configurationData);
// Now run the TestCase and configure the Network...
tcConfiguration.run;
}else
{
log.info "**************************** No Network Setup Required ************************";
}
}else
{
// The row contained no data so skip this row.......
testRunner.gotoStepByName( "DataSource Loop" );
}
Thanks,
Steve