Forum Discussion

ChristopherL's avatar
ChristopherL
Regular Visitor
8 years ago

Running multiple teststeps remotely using groovy, works stand alone, fails when remotely called

I have setup a testsuite to use a testcase called "setup" which contains multiple groovy script teststeps. Each of these teststeps is responsible for randomizing a valid set of good test data for each node in the final json object. I have created a single DataSource which is remotely called by some of the groovy setup testcases to generate a new set of data. I am using the setup script other testcases to remotely call these groovy setup scripts to setup the data needed for that testcase and finally to build the json based on what was run.

 

The issue I have is that I have tested all of these scripts independantly and they are working, and the json is being generated correctly. When I use the setup script in a separate testcase, some of the setup teststeps are failing. The ones that are failing are the ones that remotely trigger the DataSource teststep themselves. I am not sure why this works when running the script directly and why it is failing when remotely triggered.

 

My TestSuite is setup like this, I have trimmed down some of the steps for simplicity. The idea is that some of them are running, and some of them are failing. The ones that fail call the DataSource teststep.

 

  • Project
    • TestSuite
      • Setup
        • run_all
        • run_setup
        • run_pricing_id
        • run_applicant
        • run_applicant_agreement
        • run_business
        • run_business_batch_settings
        • run_json
        • run_cleanup
        • DataSource
      • TestCase1 

 

Groovy example of a testcase that is failing.

 

/***************************************************
 run_applicant.groovy

 applicant_first_name
 applicant_last_name
 applicant_phone_number
****************************************************/

/**
 applicant_first_name
 applicant_last_name
 applicant_phone_number
****************************************************/

// sets up a helper variable to shortens the call to the testcase
def testSuite = testRunner.testCase.testSuite.project.testSuites['SEPA-EUR'].testCases['Setup']

// remotely runs the teststep DataSource under the testcase Setup
testRunner.runTestStep( testSuite.testSteps['DataSource'] )

// pulls properties from the teststep 'DataSource' and assigns them to local variable
String first_name = testRunner.testCase.testSteps['DataSource'].getPropertyValue('first_name')
String last_name = testRunner.testCase.testSteps['DataSource'].getPropertyValue('last_name')
String phone_number = testRunner.testCase.testSteps['DataSource'].getPropertyValue('phone_number')

/**
 transfer properties to global testsuite
****************************************************/
testRunner.testCase.testSuite.setPropertyValue('applicant_first_name', first_name)
testRunner.testCase.testSuite.setPropertyValue('applicant_last_name', last_name)
testRunner.testCase.testSuite.setPropertyValue('applicant_phone_number', phone_number)

/**
 debug
 test that all properties are generating correctly
 uncomment and run to test
****************************************************/

log.info('applicant_first_name: ' + first_name)
log.info('applicant_last_name: ' + last_name)
log.info('applicant_phone_number: ' + phone_number)
No RepliesBe the first to reply