Forum Discussion

djeang's avatar
djeang
New Contributor
2 years ago
Solved

projectPath returns project parent directory

I Use ReadyAPI 3.20.2 

 

My project is located under c:\readyapi-projects\my-project and is shared on git

So there is on my disk :

  • c:\readyapi-projects\my-project\setting.xml  file
  • c:\readyapi-projects\my-project\.git    directory

But when I want to get the project base path using : 

 

 

 

def projectPath = new com.eviware.soapui.support.GroovyUtils(context).projectPath 
log.info projectPath

 

 

 

I get c:\readyapi-projects instead of c:\readyapi-projects\my-project

 

Does someone has an idea on how to get the path of the project (and not the parent dir) ?

  • djeang ,

    ReadyAPI allows two structures to save projects:

    • single file: the project is a single XML file, all included
    • composite: directory structure, useful for versioning and team collaboration

     

    I assume previously the projectPath (the code you mentioned above) was meant as the parent directory for single file xmls:

    log.info new com.eviware.soapui.support.GroovyUtils(context).projectPath 

     

    If you want to get the directory of the composite project structure, you may use the project method:

     

    log.info context.testCase.getTestSuite().getProject().getPath()

     

    Please note the method will return:

    • directory for composite format
    • xml file for single-file format

     

    Best regards,

    Karel

     

3 Replies

  • KarelHusa's avatar
    KarelHusa
    Champion Level 3

    djeang ,

    ReadyAPI allows two structures to save projects:

    • single file: the project is a single XML file, all included
    • composite: directory structure, useful for versioning and team collaboration

     

    I assume previously the projectPath (the code you mentioned above) was meant as the parent directory for single file xmls:

    log.info new com.eviware.soapui.support.GroovyUtils(context).projectPath 

     

    If you want to get the directory of the composite project structure, you may use the project method:

     

    log.info context.testCase.getTestSuite().getProject().getPath()

     

    Please note the method will return:

    • directory for composite format
    • xml file for single-file format

     

    Best regards,

    Karel

     

  • groovyguy's avatar
    groovyguy
    Champion Level 1

    If you look at your Project, and at the Project Properties tab, you shouyld have a property called "Resource Root." I usually set this via the drop-down menu to ${projectDir}

     

    Then, in a groovy script, you can reference it with:

     

    def projDir = context.expand('${projectDir}');
    • djeang's avatar
      djeang
      New Contributor

      This still returns parent project directory.