1. Today I ran the test case(REST API) and got the response let's say A
2. Tomorrow if I run the same test case, I may get the same response or a different response if there any changes to our config file, let's say that is B
Now, I have two responses and I need to compare both the responses A and B (both A and B are Json responses), to make sure that there are no changes OR if there are any changes, what are they( I mean where exactly the changes are additions/deletions/modification to any values in the response etc.,).
So, I am sending the responses to a text file, and in my Groovy script I am hard coding the two file paths(Previous response and Current responses) in order to read the content from those two files. I want to avoid hard coded file paths from my Groovy script. Of course I am also trying to see if there are any other alternatives to do that comparison and return the differences from both the responses, to make it simple.
Now, if some content needs to saved into file, below will do
def fileName = java.time.ZonedDateTime.now().format(java.time.format.DateTimeFormatter.ofPattern("yyyyMMdd-HHmmss"))
def fileContent = 'you can have your content or response into this variable'
//Save the content into file; you can also add the path below if you want file to be saved in different location