cancel
Showing results for 
Search instead for 
Did you mean: 

Deleting or moving a file after successful submission (SOAP Project)

Highlighted
Occasional Contributor

Deleting or moving a file after successful submission (SOAP Project)

Good day, 

 

I'm currently working on a simple test case that currently consists of the following steps:

 

1. Data Source: Folder (containing .xml files)

2. SOAP Request 

3. Data Source Loop (to iterate through and send each file found in the data source folder)

4. Assertions.

 

I would like to have a step that deletes OR moves the relative .xml request file from the data source folder after a response is received for it, would this be at all possible?

 

Thanks!

14 REPLIES 14
Highlighted
Community Hero

Re: Deleting or moving a file after successful submission (SOAP Project)

"Events" - feature can be used in this case.

TestSuiteRunListener.afterTestCase - implement this method to delete the files.
For more details, refer documentation below:
https://support.smartbear.com/readyapi/docs/testing/handling-events.html#available-events

You should be easily able to find code samples to delete file online.


Regards,
Rao.
Highlighted
Occasional Contributor

Re: Deleting or moving a file after successful submission (SOAP Project)

Thanks nmrao but I'm not having much luck with my specific scenario and finding what I need, Groovy examples seem very sparce and documentation extremly poor, and I'm having to figure this out myself. I you happen to have an example that would be much appreciated.

Highlighted
Occasional Contributor

Re: Deleting or moving a file after successful submission (SOAP Project)

Okay I have figured out a solution that will delete all files after test execution (ideally I would like them to be deleted as they receive a response but I have not found antything that would allow this) also I would love if this was a test step in the GUI of Soap UI, like 'Delete File(s)':

 

File xmlFolder = new File("C:/test/XML Files")

xmlFolder.eachFileMatch(~/.*.xml/) {
    file - >
        log.info("${file.name} will now be deleted")
    file.delete()
}

@nmrao 

Highlighted
Community Hero

Re: Deleting or moving a file after successful submission (SOAP Project)

That is possible too.

Implement "TestRunListener.afterStep" method and have your code in there.


Regards,
Rao.
Highlighted
Occasional Contributor

Re: Deleting or moving a file after successful submission (SOAP Project)

@nmrao do you know of the way to identify the current file 'in-use' by the test case? As if I place my current script in there it will delete everything when it triggers; I need to reference the correct file name in TestRunListener.afterStep.

Community Hero

Re: Deleting or moving a file after successful submission (SOAP Project)

I do not have the context "current file" or your test data structure or the way you reading files. What files are you reading actually and trying to remove it?


Regards,
Rao.
Highlighted
Occasional Contributor

Re: Deleting or moving a file after successful submission (SOAP Project)

Hi @nmrao so I'm iterating through a folder that contains .XML files. 

 

Example:

 

50 .xml files in folder: "C:/test/XML Files"

 

My SoapUI test currently iterates nicely through each file and submits them to a Soap Webservice:

 

1. Data Source: Folder (containing .xml files)

2. SOAP Request 

3. Data Source Loop (to iterate through and send each file found in the data source folder)

4. Assertions.

 

Ideally I would like my script to simply delete or move a file that was just submitted in the data source loop.

 

Thanks!

Highlighted
Community Hero

Re: Deleting or moving a file after successful submission (SOAP Project)

Then you should be able to identify which file you are iterating and delete the same file.

If you there is difficulty in identifying, then set the current file name in test case custom property and read that in the script.


Regards,
Rao.
Highlighted
Occasional Contributor

Re: Deleting or moving a file after successful submission (SOAP Project)

Yeah I know I should be able to, I need technical assistance with the method of dynamic access of current file name under test, unfortunatly this is too high level. I cannot hard code these values.

 

Thanks for trying to help though @nmrao 

New Here?
Join us and watch the welcome video:
Announcements
TechCorner Leaderboard
Want a fun and easy way to learn ReadyAPI and show off your skills? Try solving weekly TechCorner challenges and get into the Leaderboard!


Challenge Status

Compare an expected JSON value and actual response in Events

Participate!

Fetch value/data from JSON response using Groovy Script

See replies!

Filtering data retrieved from a DataSource

See replies!

Get data from Petstore and add it to Excel sheets

Participate!
Top Kudoed Authors