Forum Discussion

LZhang's avatar
LZhang
Frequent Contributor
16 years ago

Re: Can I use project path in datasource?

Hi:

Can I use

groovyUtils.projectPath + "\\FetchProviders\\Output\\providerId.txt"

in file type datasource?

Basically, I don't want to hard code the project path (since each user's path is different).  providerId.txt is created in a previous step using project path in groovy.  In the second step, I want to read the providerId.txt back into my test case using the same project path.  Is it feasible?

Thanks,
Li Zhang
  • Hello,

    Sure, that will work for you. But, I think it better to use test case property or even project property to store and retrieve file path.
    That way you can access it outside test case.

    context.testCase.properties["fileName"].value = fileName // set a value for testCase property fileName

    // in different test step
    def fileName = context.testCase.properties["fileName"].value // get it


    Also, you could use property expansion..

    Does it help,
    robert