cancel
Showing results for 
Search instead for 
Did you mean: 

${projectDir} doesn't resolve correctly

jonathon
Contributor

${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 17
nmrao
Community Hero

Re: ${projectDir} doesn't resolve correctly

Would you please show how you are using ${projectDir} with screenshot?


Regards,
Rao.
jonathon
Contributor

Re: ${projectDir} doesn't resolve correctly

Sure

 

jonathon_0-1623761821386.png

 

 

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

 

jonathon_1-1623761960854.png

 

Output is:

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

 

nmrao
Community Hero

Re: ${projectDir} doesn't resolve correctly

Thank you. Also show the screen shot of project location please.


Regards,
Rao.
HimanshuTayal
Community Hero

Re: ${projectDir} doesn't resolve correctly

@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

Click "Accept as Solution" if my answer has helped,
Remember to give "Kudos" 🙂 ↓↓↓↓↓



Thanks and Regards,
Himanshu Tayal
jonathon
Contributor

Re: ${projectDir} doesn't resolve correctly

@HimanshuTayal 

 

Unfortunately still resolves to C:

jonathon
Contributor

Re: ${projectDir} doesn't resolve correctly

@nmrao 

 

jonathon_0-1623842407111.png

 

HimanshuTayal
Community Hero

Re: ${projectDir} doesn't resolve correctly

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

 

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

 


Click "Accept as Solution" if my answer has helped,
Remember to give "Kudos" 🙂 ↓↓↓↓↓



Thanks and Regards,
Himanshu Tayal
jonathon
Contributor

Re: ${projectDir} doesn't resolve correctly

@HimanshuTayal 

 

This is being run from a test suite setup script

Caused by: groovy.lang.MissingPropertyException: No such property: testRunner for class: Script21

nmrao
Community Hero

Re: ${projectDir} doesn't resolve correctly

Where the ReadyAPI project in the above directory image?


Regards,
Rao.
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors