SoapUI NG Pro
  • Preface
  • 1. About SoapUI NG Pro
    • 1.1 Introduction to SoapUI NG Pro
    • 1.2 Application Installation Instructions
    • 1.3 License installation instructions
  • 2. Ready API - How to use
    • 2.1 Creation of Project:
    • 2.2 Test Case Creation
    • 2.3 Assertions
      • Assertions - In Nutshell
      • Groovy Request and Response Save
      • Script Assertion
    • 2.4 Data Driven Testing
  • 3. Execution in SoapUI NG Pro
    • 3.1 Running Tests From Test Steps
    • 3.2 Running Tests From Test Suites
    • 3.3 Running Test From Project Level
  • 4. Report Generation in SoapUI NG Pro
    • 4.1 Test case Level
    • 4.2 Test Suite Level
    • 4.3 Project Level
  • 5. Continuous Integration
    • 5.1 Jenkins ReadyAPI - Installation instruction
    • 5.2 CreateTests from Jenkins
    • 5.3 Run Tests from Jenkins
    • 5.4 Resolve License errors in Jenkins
Powered by GitBook
On this page

Was this helpful?

  1. 2. Ready API - How to use
  2. 2.3 Assertions

Script Assertion

In this case it is Script.

  1. Select Script Assertion and there no sub-types associated with it.

  2. Click 'Add'.

  3. The Scripting Dialog opens where user will be able to write user defined script to validate the response XML.

  4. Now let us write a groovy script to validate the Conversion Rate. The Script is attached below with the comments embedded. It is recommended to have knowledge on JavaScript or Groovy Script before attempting to write your own script.

//Define Groovy Utils and holder for validating the XML reponse content

def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
def holder = groovyUtils.getXmlHolder(messageExchange.responseContent)

//Define the NameSpace
holder.namespaces["ns"] = "http://www.webserviceX.NET/"

//Get the Value of the Node 'ConversionRateResult' and assign to a variable
def conversionRate = holder.getNodeValue("//ns:ConversionRateResult")

//print the value of the conversion rate in the Output pane
log.info "The conversion value from USD to INR is " + conversionRate

//Comparing the value to print 'Pass' or 'Fail'
if(conversionRate=="63.7854")
{ log.info "Pass" }
else
{ log.info "fail"}

Click 'Execute' Button to trigger the execution.

  1. The output of the Script is shown in the Output pane. It has printed both, Conversion Value as well as the end result (Pass or Fail)

  2. The Information is displayed that 'Script Assertion Passed'. Click OK.

Note:The final Information pop up will always display with the message 'Script Assertion Passed' as long as the script is syntactically correct. It has got no correlation with your assertion within the script.

If you want to call a particular groovy script in other test cases. Below is the format to call it

context.testCase.testSuite.testCases["<TestCaseName>"].testSteps["<TestStepName>"].run(null,context)
PreviousGroovy Request and Response SaveNext2.4 Data Driven Testing

Last updated 5 years ago

Was this helpful?