5

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

Need help to understand the difference.

Best Questions
  • 67
  • 1
  • 1
  • 4

1 Answers1

11

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 )

Gurmanjot Singh
  • 10,224
  • 2
  • 19
  • 43
SiKing
  • 10,003
  • 10
  • 39
  • 90