TestCaseA teardown runs 4 seconds after TestCaseB starts is this a bug?

50 Views Asked by At

We are using ReadyAPI 3.6.0, we use Jenkins with testrunner to execute our testsuites. I am trying to understand if I have found a bug in ReadyAPI or if it is user error.

My scenario is I have a TestSuite with TestCase A and TestCase B. For Test A in the teardown tab with Groovy script I call two testcases (TestCaseX and TestCaseY) both are needed to reset my environment before TestCaseB executes.

I have an intermittent issue, for a one of my builds, TestCase A finishes executing (as well as TestCase X from the teardown) , TestCase B starts to execute then 4 seconds later TestCase Y is executed from the teardown script of Test Case A. I was expecting the entire teardown script of Test Case A to finish executing before testrunner launches Test Case B. Is this a defect or something wrong in my teardown code? Many thanks for your support and advice.

My Groovy code in TestCase A Teardown tab is below:

// get Reset Environment Test Suite X
def resetTestSuiteX= testRunner.testCase.testSuite.project.getTestSuiteByName("Reset Test Suite X")
// get Reset Environment Test Case X
def resetTestCaseX= resetTestSuiteX.getTestCaseByName("Reset Test Case X")
// set a property in context required to execute testcase A
context.setProperty("in.opt.filename","filename1.json")
// run the testCase Y passing the context
def contextMap = new StringToObjectMap( context )
resetTestCaseX.run(contextMap,true);

// get Reset Environment Test Suite Y
def resetTestSuiteY= testRunner.testCase.testSuite.project.getTestSuiteByName("Reset Test Suite Y")
// get Reset Test Case Y
def resetTestCaseY= resetTestSuiteY.getTestCaseByName("Reset Test Case Y")
// run the testCase Y passing the contextMap (but it ignores it as it doesn't need any property to run)
resetTestCaseY.run(contextMap,true);
1

There are 1 best solutions below

0
On

This is untested code!

TestCase.run() returns a TestCaseRunner, which I believe is non-blocking. You might want to wait for it to finish. Something like:

//...
def runner = resetTestCaseX.run(contextMap, true)
runner.waitUntilFinished()

// similarly for your resetTestCaseY.run()

API reference, as sparse as it is, might be helpful.