Forum Discussion

jonathon's avatar
jonathon
Contributor
3 years ago

${projectDir} doesn't resolve correctly

Hi

 

I have a project that sits in C:\dis-hl7, I've set the ResourceRoot in the project properties as ${projectDir} and I expected this to resolve to C:\dis-hl7. But it seems to resolve to C:\. What am i missing to get it to resolve to the root of the project?

17 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3
    Would you please show how you are using ${projectDir} with screenshot?
    • jonathon's avatar
      jonathon
      Contributor

      Sure

       

       

       

      I'm using it in two places:

       

      within groovy in a suite setup script:

      import groovy.time.*
      import groovy.sql.Sql
      log.info context.expand('${projectDir}')
      ...

      Output is:

      Tue Jun 15 09:57:16 ADT 2021: INFO: C:\

       

      And also within a datasource step for a file

       

       

      Output is:

      java.io.FileNotFoundException: C:\allergy-drugs.csv (The system cannot find the file specified)

       

      • nmrao's avatar
        nmrao
        Champion Level 3
        Thank you. Also show the screen shot of project location please.
  • jonathon : Please try with the following code, hope it would resolve your issue

     

    def projectPath = new com.eviware.soapui.support.GroovyUtils(context).projectPath //gets the path of the project root
    log.info projectPath
      • HimanshuTayal's avatar
        HimanshuTayal
        Community Hero

        jonathon : I guess it is returning the correct location as it is under c:/, please try below code

         

        testRunner.getTestCase().getTestSuite().getProject().getPath()