Navigation: JunoRestClient > Advanced >

Test Case

 

Send comments on this topic.

 

 

Test Case

 

 

 

Test Case

Add a test case. Each test case must return boolean result either true or false.

 

The following example shows how to parse a JSON result from the execution result of "Get-TemplateVariables" rest service item.

After parsing, it gets the JSON field and compares with an expected value and returns the boolean result.

 

Example:

//

//           Test Case to verify the result of a REST service

//

 

import groovy.json.JsonSlurper ;

 

// Define jsonSlurper

def jsonSlurper = new JsonSlurper()

 

// Define REST service item name

def documentName = "yourservicename" ;

 

// Get Response data

def responseJson = app.getResponsePayload(documentName) ;

 

// Parse JSON object from string

def json = jsonSlurper.parseText ( responseJson ) ;

 

//

// Compare the expected result

//

def expectedId = 1 ;

 

def result = json[0].id == expectedId ;

//

// Returns the result

//

return result ;

 

 

 

 

 

Copyright © 2016 junorestclient.com

www.JunoRestClient.com