Forum Discussion
Thanks for the query!
Let's asl the Community to help, perhaps some folks faced similar use cases.
PrathapR ChrisA HimanshuTayal groovyguy avidCoder
any thoughts?🙂
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)
}
- Sirisha20205 years agoContributor
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,
Related Content
Recent Discussions
- 15 hours ago