Forum Discussion

mlipanje's avatar
mlipanje
New Contributor
4 years ago

Get report directory in groovy code

Is it possible to retrieve current report directory in groovy code? 

I set report dir through CLI (parameter -f%reportdir%) and I'd like to save files to that directory in groovy code.

 

Thanks for your help

Regards.

  • Hello mlipanje

     

    After some considerable looking, I could not find the simple solution... 😞

     

    The work around could be to use a project parameter as a proxy for the report dir you have defined...  In addition to -f parameter, include a -P parameter and reference that in your groovy code.

    CLI would have additional parameter...

    ...  -P"outputDirectory=%reportdir%-f%reportdir%   ...

     

    Then in groovy code where you need to reference the location to save files to...

    def projectoutputDirectory = testRunner.testCase.testSuite.project.getPropertyValue( "outputDirectory" );
    log.info "projectoutputDirectory=$projectoutputDirectory";    // the directory you defined for -f and -P parameter
    

    Hope that can help.

    Regards,

    Todd

     

     

  • TNeuschwanger's avatar
    TNeuschwanger
    Champion Level 1

    Hello mlipanje

     

    After some considerable looking, I could not find the simple solution... 😞

     

    The work around could be to use a project parameter as a proxy for the report dir you have defined...  In addition to -f parameter, include a -P parameter and reference that in your groovy code.

    CLI would have additional parameter...

    ...  -P"outputDirectory=%reportdir%-f%reportdir%   ...

     

    Then in groovy code where you need to reference the location to save files to...

    def projectoutputDirectory = testRunner.testCase.testSuite.project.getPropertyValue( "outputDirectory" );
    log.info "projectoutputDirectory=$projectoutputDirectory";    // the directory you defined for -f and -P parameter
    

    Hope that can help.

    Regards,

    Todd