Forum Discussion

AIG_OneClaim_Su's avatar
AIG_OneClaim_Su
New Contributor
12 years ago

Passing Dynamic Datasink

Hi,

We want to use Datasink to write the report into an excel sheet which will be created dynamically for each project run. The steps look as below:

1. Storing the result in a static Excel sheet. (Ex: C:/Users/abc/Desktop/abc.xls)
2. Creating the new excel sheet dynamically after each run using Groovy script.
(A code snippet: WritableWorkbook workbook = Workbook.createWorkbook(new File("path"+dateandtime+".xls")))
3. Adding a Property transfer step to fetch the path of the created script into "Test Case level property"
4. Transferring the path of the created Excel sheet into new Datasink (here we give something like "${#TestCase#Path}" in the browse field

Now our problem is SOAPUI searches for ${#TestCase#Path}, namely, Step 4 even before the excel has been created in Step 2. And we get the below error:

TestCase failed [java.lang.Exception: Failed to prepare testStep [DataSink Current result]; java.io.FileNotFoundException: C:\Users\abc\Desktop\Results-2014-02-12-15-14-20.xls (The system cannot find the file specified), time taken = 0

Could anyone help me on using the Datasink to write to a dynamically created Excel file.

3 Replies

  • PaulDonny's avatar
    PaulDonny
    Regular Contributor
    What is causing it to look for the file? Based on that error message it is attempting to either read or write from the file prior to creation. Something has to be causing this.

    If you just want to fix the error, create the file during a Setup script. If you want to fix the underlying problem, don't do any reporting until your teardown script and then just grab the data from your steps after they have happened.
  • Hi,

    Thanks for the response. It is still throwing the same error even if I create the excel file at the first step. I was not able to understand the second solution. Could you please elaborate.
  • PaulDonny's avatar
    PaulDonny
    Regular Contributor
    With SoapUI there is TearDown/Save scripts which are located at the bottom of the screen that will run when the TestCase/TestSuite/Project has finished running (depending on where you put the script). This will allow you to perform tasks like logging after the script(s) have completed. This should be where logging is performed typically. I do recommend setting up a project level property that will enable or disable logging in order to make it easier to control though.