Forum Discussion

Jan_Stepan's avatar
Jan_Stepan
Occasional Contributor
16 years ago

Resource Root in 2.5.1

A previous post indicated the ${projectDir} variable may not be working in version 2.5.1.

Whether I set the project "Resource Root" property to ${projectDir} or put in an absolute path.

In both cases a debug in a test case set up script returns nothing.

log.info context.expand( '${#Project#Resource Root}');

7 Replies

  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi,

    If I understand you correctly, and you were trying to
    run your code from TestCase set up script, you should check the output at Groovy log. Hope that's what you where looking for.

    Regards,

    /Dragica
    eviware.com
  • dragicas's avatar
    dragicas
    New Contributor
    Hi Jan,

    Very sorry for giving you a misleading answer, it seems I didn't understand you wright .
    What you really need to do in setup script is


    log.info context.testCase.testSuite.project.resourceRoot;


    the output you should get will be in groovy log

    Regards

    /Dragica
    eviware.com
  • Jan_Stepan's avatar
    Jan_Stepan
    Occasional Contributor
    debug code
    log.info context.testCase.testSuite.project.resourceRoot;


    In a test case setup script the above debug code returns

    java.lang.NullPointerException


    In a groovy test case step the above debug code returns

    Fri Mar 20 17:53:13 PDT 2009:INFO:C:\Temp


    or

    Fri Mar 20 18:04:13 PDT 2009:INFO:${projectDir}
  • Jan_Stepan's avatar
    Jan_Stepan
    Occasional Contributor
    After more testing I think context does not work at the test suite or test case level.

    I can get the value in Resource Root at the test suite setup script with:

    log.info testSuite.project.resourceRoot;

    or at the test case level with:

    log.info testRunner.testCase.testSuite.project.resourceRoot;

    BTW why does ${projectDir} fail to resolve. If I set Resource Root this value, which is in the drop down, the above debug returns the the string "${projectDir}". I'd expect the actual project folder value .
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi Jan,

    you need to expand value to get its actual value with something like

    def resourceRoot = testRunner.testCase.testSuite.project.resourceRoot
    resourceRoot = com.eviware.soapui.model.propertyexpansion.PropertyExpansionUtils.expandProperties( resourceRoot )

    Hope this helps!

    regards,

    /Ole
    eviware.com
  • Jan_Stepan's avatar
    Jan_Stepan
    Occasional Contributor
    Ole,

    At the test suite level when Resource Root is ${projectDir}

    def resourceRoot = testSuite.project.resourceRoot
    resourceRoot = com.eviware.soapui.model.propertyexpansion.PropertyExpansionUtils.expandProperties( resourceRoot )

    resolves to null.

    For the time being I've had to explicitly set (hard code) Resource Root to to my project folder path.
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hello,

    Do it like this:



    def resourceRoot = testRunner.testCase.testSuite.project.resourceRoot
    log.info context.expand( resourceRoot )



    Let me know if this helps,

    robert