Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What t is the difference between "Context" and "TestRunner" in SOAPUI?

Tags:

groovy

soapui

While writing groovy in SOAPUI some times we use context and some times we use TestRunner,

Need help to understand the difference.

like image 689
Best Questions Avatar asked Aug 07 '14 13:08

Best Questions


People also ask

What is TestRunner and context in SoapUI?

The TestRunner is the object that is actually executing the TestCase by cycling through the TestSteps in the TestCase and executing them. It exposes methods related to test execution and the underlying object model (via the testCase property). Common usage scenarios are: using testRunner.

What is context in groovy script?

Context holds information about the environment and is required to freely navigate in the mentioned environment. @dmahapatro: context available in groovy scripts in SoapUI is the context of executions of a test case/test suit.


1 Answers

From the documentation:

  • testRunner - a TestCaseRunner object, which is the entry-point to the soapUI API for accessing project items, results, etc. The testRunner is the object that is actually executing the TestCase by cycling through the TestSteps in the TestCase and executing them. It exposes methods related to test execution and the underlying object model (via the testCase property). Common usage scenarios are:

    • using testRunner.testCase to get hold of the containing TestCase from which all other objects in the project can be accessed and manipulated
    • using testRunner.fail(...) (or testRunner.cancel) to abort the ongoing TestCase when an error occurs
    • using testRunner.gotoStepByName(...) or testRunning.runTestStepByName( ... ) to transfer execution to another step than the one after the Script TestStep in the TestCase (see ...)
  • context - a TestCaseRunContext object holding context-related properties. The main usage for this is to store values that can be used in subsequent TestSteps or related scripts. For example

    context.myProperty = "Hello"

    will create a property named "myProperty" in the context and assign it the string value "Hello". In a subsequent script, you can access it with

    log.info( context.myProperty )

like image 192
SiKing Avatar answered Nov 15 '22 09:11

SiKing