ContributionsMost RecentMost LikesSolutionsRe: Retry based on AssertionStep status I managed to solve this specific problem, the opened support request shall remain open because I still suspect a problem with the .run() function. Instead of trying to emulate the testRunner from inside the groovy step we now "drop an anchor" before the retry-cycle, run into the script and check the checkpoint status. If the status is FAIL we tell the testRunner to go back to the anchor via testRunner.gotoStep() - if the status is PASS we just let the TestCase continue on. Here is how that looks: The anchor contains the number of remaining retry attempts, which are subtracted with each iteration by the ftpRetry-Script. And here is the adapted ftpRetry function from the example. void ftpRetry(def testRunner, def context){ // variables to allow user to specify other names List<String> retryCheckpointNames = ['retryCheckpoint'] List<String> retryAnchorNames = ['retryAnchor'] int defaultRetryCount = 15 ( checkpointStep, checkpointIndex ) = findStepInTestCase(context, true, retryCheckpointNames) ( anchorStep, anchorIndex ) = findStepInTestCase(context, true, retryAnchorNames) if(checkpointStep.getAssertionStatus().toString() != 'PASS') { // checkpoint did not pass, get the anchor, set the testRunner to the index of the anchor and subtract a retry from the anchor, then let everything run until this script is called again int retries = anchorStep.getPropertyValue('retries').toInteger() if(retries-- > 0) { anchorStep.setPropertyValue('retries', retries.toString()) testRunner.gotoStep(anchorIndex + 1) } else { anchorStep.setPropertyValue('retries', defaultRetryCount.toString()) assert false : "Out of retries, checkpoint-assertion failed every time!" } } else { log.info("Checkpoint passed, resetting retries on anchor.") anchorStep.setPropertyValue('retries', defaultRetryCount.toString()) } } Should have reconsidered my approach to the problem rather than trying to force the script to emulate the testRunner, oh well. Re: Retry based on AssertionStep status At this point I am 100% sure that calling .run() on the AssertionTestStep does not execute any AssertionEntry. I can not figure out how to emulate the actual testRunner, my best attempt to run the entries follows: def assertionStep = context.getTestCase().getTestStepAt(context.getCurrentStepIndex() + 4) assertionStep.getAssertionEntryList() .each{ assertionEntry -> assertionEntry.getAssertion().assertRequest(?????, context) }.collect { assertionEntry -> assertionEntry.getStatus() } The problem right now is that assertRequest() requires the MessageExchange object, but I have no idea how to get the MessageExchange from the previous RestRequest, the API is very undocumented and after a day of digging I could not find a way to make it work. Re: Retry based on AssertionStep status HimanshuTayal Thanks for the help so far, but sadly your code produces a "PASS" as well. Re: Retry based on AssertionStep status HimanshuTayalSame problem sadly. I can guarantee that the step called has assertions can would lead to a failure, I am currently assuming that calling .run() just doesn't actually execute the assertions, so the "empty" AssertionStep is being executed and 0 assertions = 0 fails, so the step itself passes. Retry based on AssertionStep status Hi there Intro here, the actual problem is below the line. We are currently working on a retry-mechanism that re-runs a specific interval of testSteps upon failure. In the given picture the test would transfer a file to a server, which extends an already existing list with new data. Because the processing system is outside of our scope we can only wait and guess when the server is done ingesting and processing the data. In the current project we wait for a static 2 Minutes (and it still takes longer sometimes). The entire logic would be to simulate a testRunner and have the script run all steps from index 2 to 5, check the assertion step at index 5 and then continue the testCase. Upon failure it would run all steps from index 3 to 5 again. The pure logic is rather basic and would look like this: void ftpRetry(def testRunner, def context, int retries){ List retryCheckpoints = ['retryCheckpoint'] int currentIndex = context.getCurrentStepIndex() ( checkpointStep, checkpointIndex ) = findStepInTestCase(context, false, retryCheckpoints) Boolean passCheckpoint = false while(retries-- > 0 && !passCheckpoint){ runTestSteps(testRunner, context, currentIndex + 1, checkpointIndex) if(checkpointStep.getAssertionStatus().toString() == 'PASS') { passCheckpoint = true } } assert passCheckpoint : "Out of retries, checkpoint-assertion failed every time!" } void runTestSteps(def testRunner, def context, int startIndex, int endIndex) { while(startIndex <= endIndex) { context.getTestCase().getTestStepAt(startIndex++).run(testRunner, context) } } ________________________________________________________________________________________ The script looks fine to me, but calling .getAssertionStatus() on the AssertionStep always returns "PASS". It appears as if the step itself runs, but the assertions within the step are not running because their status is always "UNKNOWN". This may have something to do with the AssertionStep itself, but we currently can not use internal assertions in REST-Steps themselves. We must put assertions in their own step! I am currently crawling through the API to figure out why the assertions within the assertionStep don't want to run, but I'd like to see if someone can provide a solution. SolvedRe: Controlling FTPTestStep from groovy Thanks to the support for solving the problem: The ftpStep requires two additional method calls to properly transmit files, using the provided example in the OP the correct way to use the run method would be as follows: new File(path).listFiles().each{ ftpStep.setLocalPath(it.getPath()) ftpStep.setFileName(it.getName()) ftpStep.prepare(testRunner, context) ftpStep.run(testRunner, context) ftpStep.finish(testRunner, context) } Re: Controlling FTPTestStep from groovy The verification of functionality for methods offered by their API should be covered by the developer - which would be smartbear. If the function does not work, it should be fixed or in the worst case flagged as deprecated. The documentation of the class Though I still don't actually know if the function doesn't work or it's a problem with my local machine because no one has attempted to reproduce the bug. It is perfectly plausible that I just messed something up when I pass the variables - which a more savy person should identify immediately - which is the whole reason I created this forum post. I did not want to directly ask support to help me with groovy issues. Re: How to handle Unparsable JSON string in groovy I'd use the following function to validate json import groovy.json.JsonSlurper Boolean isValidJson(jsonString){ result = true try{ new JsonSlurper().parseText(jsonString) } catch(Exception e){ result = false } return result } And then call the validation before passing the values to assertEquals: assert isValidJson(response) == true assert isValidJson(step_response) == true JSONAssert.assertEquals(step_response,response,false) Instead of asserting it to true, you can also just use an if() to handle the malformatted json as you see fit. Re: Controlling FTPTestStep from groovy I do not have access to the machine outside of FTP transfer. I can not insert any code or logic that unzips archive files on the machine. I do not have the ability to set up my own server, put my .zip on that server and tell that server to transfer the files to the target system. I MUSTsend each file on its own. No wiggle room here. Thank you for your help, but I'd like to ask you to just confirm the problem with the run function in ftp-steps so I can create a support request. Re: Controlling FTPTestStep from groovy I'm afraid I don't understand what you are suggesting. I can not provide you with example files that need to be uploaded if that's what you are suggesting, as they contain sensitive data. And yes, it would be faster to just send an archive, but we are required to send single files, the system that receives the files is very old and we are not allowed to modify it. Could you please attempt to reproduce the behaviour of the FTP-Step so I can create a Support Request?