Forum Discussion

MikeLoundes's avatar
MikeLoundes
Contributor
12 years ago

Unable to remove file

Hi

I'm having an issue with some temp files I generate being locked and I'm then unable to remove them unless I close SoapUI

I have some tests which call out to another project file which extracts some data from a backend db and creates some datasinks of csv format for use in the main test

I have the following code which is intended to remove any existing files on an iteration of data driven testing


log.info ' Deleting files'
def CurrentDir = new File(groovyUtils.projectPath).parent
def getPartyDetails = context.expand( '${#Project#GetPartyDetails}' )
def getPartyPhoneDetails = context.expand( '${#Project#GetPartyPhoneDetails}' )
def getPartyEmailDetails = context.expand( '${#Project#GetPartyEmailDetails}' )
def getPartyAddressDetails = context.expand( '${#Project#GetPartyAddressDetails}' )

[new File(CurrentDirStr+getPartyDetails),
new File(CurrentDirStr+getPartyPhoneDetails),
new File(CurrentDirStr+getPartyEmailDetails),
new File(CurrentDirStr+getPartyAddressDetails)].
each{ it.delete() } //delete files

log.info ' Checking files deleted'
assert ! new File(CurrentDirStr+getPartyDetails).exists()
assert ! new File(CurrentDirStr+getPartyPhoneDetails).exists()
assert ! new File(CurrentDirStr+getPartyEmailDetails).exists()
assert ! new File(CurrentDirStr+getPartyAddressDetails).exists()



the issue I'm having is that as the main test iterates through the rows of data the ds's created are not always being removed and I end up with a mix of data in the ds that is then causing failures in my assertions when cross referencing the ds data with service response data

after running the main test If I dip into the script test step that deletes the files and run it I get the error below which shows that the file is not being deleted

Assertion failed: assert ! new File(CurrentDirStr+getPartyDetails).exists() | | | || | | | | || true | | | |SoapUI_DS_PartyDetails.csv | | | C:\Users\Public\Documents\SoapUI\SoapUI_DS_PartyDetails.csv | | C:\Users\Public\Documents\SoapUI\ | C:\Users\Public\Documents\SoapUI\SoapUI_DS_PartyDetails.csv false error at line:


is there a way of forcing a close, file release before I attempt the delete?

thanks
Mike

15 Replies