Forum Discussion

thinker's avatar
thinker
Occasional Contributor
10 years ago

[Ready! API 1.3.1]DataSource file path works in UI, failed from java runner with project properties

Hi Team,

 

I am using SoapUI Pro, Ready! API 1.3.1.

 

Currently I want to pass the file path from jUnit to SoapUI project properties and use that value in DataSource input file path.

 

JAVA:

 

        properties[0] = "searchForProductsInputFile=price_input_201507.csv";
        SoapUITestCaseRunner runner = new SoapUITestCaseRunner();
        runner.setProjectFile("/Users/Catalog-int-jbo-101-remote-soapui-project.xml");
        runner.setProjectProperties(properties);
        runner.run();

 

In SoapUI

Project level,  add customer properties: searchForProductsInputFile

 

In DataSource Step,

DataSource: File

File: /Users/${#Project#searchForProductsInputFile}

 

 

However,  Seems the Datasource step doesn't pick up and read the input file.

 

Wierd thing is I tried to set customer properties: searchForProductsInputFile manual in the project level.  The file is able to be read.

 

 

Any hints,  or let me know if need further information to help out.

 

Thanks in advance

Charles

 

 

  • I figured it out.

     

    Since datasource is pro-related function. SoapUIProTestCaseRunner should be used. That is why the testcase is working in SoapUI, but failed when it is called from jUnit.

     

    import com.eviware.soapui.tools.SoapUITestCaseRunner;

    -->

    import com.eviware.soapui.SoapUIProTestCaseRunner;

  • nmrao's avatar
    nmrao
    Champion Level 3
    If you are using it in groovy script, try replacing value as context.expand('${#Project#searchForProductsInputFile}') and see.
    • thinker's avatar
      thinker
      Occasional Contributor

      Hi Rao,

       

      Thanks for replying.  I tried with groovy script. The result is the same,  it works when I run in SoapUI,  but if I invoke with JAVA runner,  it failed. 

       

      I think point is why it is working in UI,  but with same test project, when invoke from JAVA runner,  the input file is not accessiable.

       

      I attached some screenshots and codes.  Any hint or guess is welcome.

      ---


      def searchForProductsInputFile = context.expand( '${#Project#searchForProductsInputFile}' )

      testRunner.testCase.testSteps['data massage holder'].setPropertyValue("filePath", searchForProductsInputFile)

      def filePath = context.expand( '${data massage holder#filePath}' )
      log.info filePath

      ---

       

       

      Thanks again

      Charles

      • nmrao's avatar
        nmrao
        Champion Level 3
        I am really sorry to come back, what do you mean by java runner?