Forum Discussion

neptun2000's avatar
neptun2000
Visitor
7 years ago

How to pass properties between test suites using test runner command line

Hello all,

 

I am facing an issue, where in my first test suite I am at the last test case I am storing a token I have received in a project property.

 

The code I am using in my SoapUI script to do so is:

testRunner.getTestCase().getProject().setPropertyValue("whRefreshToken",          json.refresh_token)

 

in my next test suit, I am trying to read this property.

I use the following code:

def whRefresh = testRunner.getTestCase().getProject().getPropertyValue("whRefreshToken")

log.info "* * * * : whRefresh=" + whRefresh

 

 

when I run the test suites project using the SoapUI GUI, all is working well, and I can see in the debug output console that the token was retrieved successfully.

The problem occurs when I run these tests from command line.

 

This is the first command line to retrieve the token and store it in the propery:

"C:\Program Files\SmartBear\ReadyAPI-2.2.0\bin\testrunner.bat" -FPDF - -c"UC1: Obtain a WhBearerToken" -f"c:\Test Harnesss\Project Report" "C:\Test Harnesss\Gxp Automated Test Harness Baseline-readyapi-

project.xml"

 

This is the second command line to retrieve the token from the stored property.

"C:\Program Files\SmartBear\ReadyAPI-2.2.0\bin\testrunner.bat" -FPDF -D -c"Get Token" -f"c:\Test Harnesss\Project Report" "C:\Test Harnesss\Gxp Automated Test Harness Baseline-readyapi-project.xml"

 

This time I see in the output a different token retrieved from the stored property.

What it does, it actually retrieve the property value that I can also see in the SoapUI properties GUI. I can see in the properties list the token with that old value and not the new value stored due to first command line test suite run.

 

I guess , I do not pass properties correctly between tests suits.

 

This is a major blocker for me and won't much appreciate any kind of help.

 

Thanks in advanced

1 Reply

  • nmrao's avatar
    nmrao
    Champion Level 3
    1. Each test case should be independent.

    2. If some property is required and need to make it available for the project, then store it at project level custom property.

    The script that does the above is:
    context.testCase.testSuite.project.setPropertyValue("PropertyName", "value")


    If you need to use the above property with in the project is to use property expansion i.e.,
    ${#Project#PropertyName}

    If the same property needs to be read in a groovy script, use context.expand('${#Project#PropertyName}')