delete or clear excel xlsx file
Hi there,
I use a xlsx file to basically buffer some reference data. In the first step I generate that data, write it to a xlsx file and later get that data back from the xlsx file to compare it against the response of a Rest get request.
To make sure that I only have the data generated in the current run I delete the files in an initial step using this groovy script:
def prjPath = context.expand('${projectDir}') new File("${prjPath}/reports.xlsx").delete() new File("${prjPath}/reportDates.csv").delete()
I can see from a command line and the explorer that the file is deleted but once I access it at the end of the above described process again the file contains the old data and the new data is appended to the data from the previous ran.
I assume this is some funny Windows magic which is caused by Windows not really deleting the file and by generating it with the 'Append' check box activated I basically retrieve the file from the trash and append the new data to it?
Therefore, I would like to ask you whether you know of any good way to either REALLY delete these files or clear the content of the files.
Thanks a lot!
I took the opportunity to ask Nicolas Chara during a different service request about this issue and he pointed me towards setup and teardown scripts. This seems to do the trick which I assume is because it runs before the initialization procedure of the Test Case.
For later reference as I had some trouble finding it: The TestCase specific setup and tear down scripts can be found when clicking on the TestCase than shows TestSteps and than on the bottom Setup Script