Forum Discussion

JGimber's avatar
JGimber
Occasional Contributor
11 years ago

Accessing project properties from TestRunner

Hi,

 

I have hit a problem with test runner.

 

I have a project, and this has a set of project custom properties, such as "dtToday" which se set to today's date.

 

I also have some tests, which expand and use dtToday in their requests, e.g.

  • <sch:TargetDepartureTime>${=project.getPropertyValue("dtNextWeekDayMidday")}</sch:TargetDepartureTime>

or

  • <sch:TargetDepartureTime>${#Project#dtToday}</sch:TargetDepartureTime>

 

Now here's where it gets weird.

 

If I run the tests from within ReadyApi, the tests all run, and the project variables are used in the requests.  Great. :manhappy:

 

BUT...

 

If I right-click on the project, and select <Launch TestRunner> then the tests are run, but the project variables aren't accessed / used.  This naturally causes the requests to fail.  Not great.  :mansad:

 

Is there something I need to do, to tell TestRunner to use these project variables?

(ReadyApi 1.2.2, Win7).

 

Any help gratefully received!

 

Thanks

 

John.

9 Replies

  • JGimber's avatar
    JGimber
    Occasional Contributor

    Additional info:

     

    The code segment I have is this:

     

        // Get (today)
        log.info "Today = " + context.expand('${#Project#dtToday}')
        log.info "Today context = " + context.testCase.testSuite.project.getPropertyValue("dtToday")
        log.info "Today testrunner = " + testRunner.testCase.testSuite.project.getPropertyValue( "dtToday" )

     

    and when I run this from within ReadyApi, I get this output:

     

    • Mon Mar 09 14:46:52 GMT 2015:INFO:Today = 2015-03-09
    • Mon Mar 09 14:46:52 GMT 2015:INFO:Today context = 2015-03-09
    • Mon Mar 09 14:46:52 GMT 2015:INFO:Today testrunner = 2015-03-09

    but when I run it from TestRunner, I get this:

     

    14:49:24,123 INFO  [log] Today =
    14:49:24,164 INFO  [log] Today context =
    14:49:24,169 INFO  [log] Today testrunner =

     

    Hope that clarifies things a bit more...

    • nmrao's avatar
      nmrao
      Community Hero

      I got 1.0.0, where it is showing log details correctly for the mentioned case using launch TestRunner.

       

      Would it be possible to share your log when launched with TestRunner? Do you see anything in soapui.log, soapui-error.log, script.log files?

      • JGimber's avatar
        JGimber
        Occasional Contributor

        Hi Rao

        I'm running ReadyAPI 1.2.2

        Here's the log from running the script:

        Running Ready! API TestRunner for [TestProject LTS (TestProject DATA)]
        directory: C:\Program Files\SmartBear\ReadyAPI-1.2.2\bin\.
        command: cmd.exe /C testrunner.bat -sSetup -r -a -j -f"S:\TestProject SoapUI Reports" -E"Internal Dev" -o -R"JUnit-Style HTML Report" "S:\Work\TestProject LTS\SoapUI - TestProject Data\TestProject-LTS-soapui-project.xml"
        log4j:ERROR No appender named [CONSOLE] could be found.
        log4j:WARN No appenders could be found for logger (com.netflix.governator.lifecycle.ClasspathScanner).
        log4j:WARN Please initialize the log4j system properly.
        log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
        Configuring log4j from [C:\Program Files\SmartBear\ReadyAPI-1.2.2\bin\soapui-log4j.xml]
        09:33:57,228 INFO  [DefaultSoapUICore] initialized soapui-settings from [C:\Users\jgimber\soapui-settings.xml]
        09:33:57,355 INFO  [SoapUIProGroovyScriptEngineFactory] Setting Script Library to [S:\GroovyLib]
        09:33:57,356 INFO  [DefaultSoapUICore] Adding listeners from [C:\Program Files\SmartBear\ReadyAPI-1.2.2\bin\listeners\demo-listeners.xml]
        09:33:57,977 INFO  [PluginManager] 0 plugins loaded in 1 ms
        09:33:57,977 INFO  [DefaultSoapUICore] All plugins loaded
        09:33:58,390 INFO  [WsdlProject] Loaded project from [file:/S:/Work/TestProject%20LTS/SoapUI%20-%20TestProject%20Data/TestProject-LTS-soapui-project.xml]
        09:33:58,493 INFO  [SoapUIProGroovyScriptEngineFactory] Setting Script Library to [S:\GroovyLib]
        09:33:59,030 INFO  [SoapUIProTestCaseRunner] Running tests in project [TestProject LTS (TestProject DATA)]
        09:33:59,059 INFO  [SoapUIProTestCaseRunner] Running TestSuite [Setup], runType = SEQUENTIAL
        09:33:59,066 INFO  [SoapUIProTestCaseRunner] Running TestCase [Project Setup]
        09:33:59,081 INFO  [SoapUIProTestCaseRunner] running step [Copy of Setup Script]
        09:33:59,355 INFO  [log] --------------------------------------------------------------------------------
        09:33:59,355 INFO  [log] TEST SETUP 2
        09:33:59,355 INFO  [log] --------------------------------------------------------------------------------
        09:33:59,366 INFO  [log] Today =
        09:33:59,408 INFO  [log] Today context =
        09:33:59,413 INFO  [log] Today testrunner =
        09:33:59,413 INFO  [log] Tomorrow =
        09:33:59,413 INFO  [log] Next Weekday =
        09:33:59,413 INFO  [log] Next Saturday =
        09:33:59,414 INFO  [log] Next Sunday =
        09:33:59,414 INFO  [log] --------------------------------------------------------------------------------
        09:33:59,414 INFO  [log] TEST SETUP COMPLETED
        09:33:59,414 INFO  [log] --------------------------------------------------------------------------------
        09:33:59,418 INFO  [SoapUIProTestCaseRunner] Finished running TestCase [Project Setup], time taken: 330ms, status: FINISHED
        09:33:59,421 INFO  [SoapUIProTestCaseRunner] TestSuite [Setup] finished with status [FINISHED] in 359ms
        
        09:33:59,792 INFO  [SoapUIProTestCaseRunner] Created report [JUnit-Style HTML Report] to path [file:/S:/TestProject%20SoapUI%20Reports/Setup/index.html]
        
        Ready! API 1.2.2 TestCaseRunner Summary
        -----------------------------
        Time Taken: 777ms
        Total TestSuites: 1
        Total TestCases: 1 (0 failed)
        Total TestSteps: 1
        Total Request Assertions: 0
        Total Failed Assertions: 0
        Total Exported Results: 1
        
        09:33:59,880 INFO  [SoapUIProTestCaseRunner] Created report at file:/S:/TestProject%20SoapUI%20Reports/index.html