krogold
4 years agoRegular Contributor
Setup script execution from another groovy step
Hello, I have several testCases in my project for which the setup script cleans the properties (generated dynamically during testCase execution). In order to clean my project before GIT commit, I wi...
- 4 years ago
Finally I found out how to do it : it requires to modify context.ExecutionID
/* check setup scripts if those contain testRunner.testCase.getPropertyList().each{ testRunner.testCase.removeProperty(it.name) } it means that, prior to execution the setup script will clear data that will be (re)created during test execution it means that this data is likely to be detected as a relevant modification in git though it is not to avoid this this script will detect which test has such a setup script and will execute the setup script in order to delete these dynamic properties */ testRunner.testCase.testSuite.project.testSuiteList.each { suite -> name = suite.getName() if ((name.contains("USE CASES -"))||(name.contains("TOOLS - Configuration"))) { suite.testCaseList.each{ TC -> if ((TC.setupScript != null)&&(TC.setupScript.contains("removeProperty"))) { s_script = TC.setupScript // store the script TC.setSetupScript(null) // clear setup script // neutralize init_test_case sscript = s_script.replace("setup.init_test_case","//setup.init_test_case") sleep(1000) TC.setSetupScript(sscript) // replace initial setup script // execute the modified setup script to clean properties without launching init context.ExecutionID = TC.config.id TC.runSetupScript(context, testRunner) // restore initial setupScript // re-enable setup init TC.setSetupScript(s_script) } } } }