Forum Discussion
Hi,
Before looking at writing requests and responses, are you sure your script is correctly iterating over the test steps and 'picking' up the step name?
Try using log.info to check. E.g. in your loop....
testSuite.testCases.each { testCaseName, testCase ->
log.info("TestCaseName " + testCaseName);
// path for this testCase
def folderPathSuite = folderPath + testCaseName + File.separator;
new File(folderPathSuite).mkdir();
// for each testStep
testCase.testSteps.each { testStepName, testStep ->
log.info("TestStepName " + testStepName);
def response = testStep.getProperty('Response').getValue();
log.info(response);
if(response){
// define a file
def file = new File(folderPathSuite + testStepName + '_response.json')
// get the response and write to file
file.write(response)
}
The below code is not working and it is giving some errors
- ChrisA5 years agoContributor
Hi,
It will throw errors as it is incomplete, for example the loop is not closed.
It's purely an example excerpt from your original code just to suggest where you might want to try some logging to see if the loop is working as intended.
- Sirisha20205 years agoContributor
Hi Chris,
I closed the loop but still i am getting some other errors which i am not aware of them. We are trying to find is there a way to save request and response in REST API services on test suite level. I am in novice in groovy script.
Thanks,
- ChrisA5 years agoContributor
Hi,
Your groovy script is looking pretty good, keep going.
Would you like to post what you have currently? It would be nice if you could tell us what the errors are and where in your code they occur.
Related Content
Recent Discussions
- 15 hours ago