Forum Discussion

msandoval's avatar
msandoval
Occasional Contributor
11 months ago
Solved

Correct way to set project file path for WsdlProjectPro in composite project

hi,

i'm working with a composite project and I'm trying to declare the project variable as mentioned on the docs (under Workspace-related scripts) but I'm not sure on which file path I'm supposed to put in

 

code from docs:

 

 

import com.eviware.soapui.impl.wsdl.WsdlProjectPro

WsdlProjectPro project = new WsdlProjectPro("The full path to the project file")

 

 I tried the following:

 

  • using the file project.content
  • using the project folder path

neither of those work, so, which is the correct path I need to put in?

also, this is the current path of the project folder:  C:\git\TestProject


Thanks!😀



  • Hi,

    I got the solution via Smartbear support last week so here they are:

     

    import com.eviware.soapui.impl.wsdl.WsdlProjectPro
    
    // option 1
    def path = context.expand( '${=project.getPath()}' )
    log.info("loading from path in context")
    def project1 = new WsdlProjectPro(path) // <-- this was the code I was looking for at the beginning
    
    // option 2
    log.info("loading from testRunner.getTestCase().getTestSuite().getProject()")
    def project2 = testRunner.getTestCase().getTestSuite().getProject()

    option 1 gave me an iss ue where it wasn't updating some test project variables =C

    option 2 was the winner 😃

     

4 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3

    Understand. "workspace" object is not suggested to use for independent projects or tests executed by CLI .

     

    What command are you using to execute the tests in the pipeline?

     

  • msandoval's avatar
    msandoval
    Occasional Contributor

    Hi,

    I got the solution via Smartbear support last week so here they are:

     

    import com.eviware.soapui.impl.wsdl.WsdlProjectPro
    
    // option 1
    def path = context.expand( '${=project.getPath()}' )
    log.info("loading from path in context")
    def project1 = new WsdlProjectPro(path) // <-- this was the code I was looking for at the beginning
    
    // option 2
    log.info("loading from testRunner.getTestCase().getTestSuite().getProject()")
    def project2 = testRunner.getTestCase().getTestSuite().getProject()

    option 1 gave me an iss ue where it wasn't updating some test project variables =C

    option 2 was the winner 😃

     

  • nmrao's avatar
    nmrao
    Champion Level 3

    What is the use case? Are you trying to read another project1 from project2?

    • msandoval's avatar
      msandoval
      Occasional Contributor

      Hi,

       

      We are trying to execute our test via CLI to add it to our pipeline.

      Currently in the project I'm using the workspace object in our scripts and the test runner doesn't support that.

      In our code we set our project variable like this:

       

      this.project = testRunner.getTestCase().getTestSuite().getProject().getWorkspace().getProjectByName('Tests')

       

      And that get's us this error:

       

      Caused by: java.lang.NullPointerException: Cannot invoke method getProjectByName() on null object

       

      So we need to change it.

      Hope that helps