Ask a Question

[TechCorner Challenge #16] Compare an expected JSON value and actual response in Events

sonya_m
SmartBear Alumni (Retired)

[TechCorner Challenge #16] Compare an expected JSON value and actual response in Events

Hello ReadyAPI Сommunity!

 

We are bringing more awesome tasks your way🙂 Check out the participation rules and the TechCorner Leaderboard here.

 

In this task, we will have a scenario where you will be comparing an expected JSON value from your Data Source and the actual JSON response. This can be done in a separate Groovy Script test step or in the Script assertion but for this task, we are asking you to do so in the RequestFilter.afterRequest event.

 

Task: Compare an expected JSON and actual response in the event

Difficulty: Star_Gold.pngStar_Gold.pngStar_gray.png

 

In your script, you will be fetching the expected response from your Data Source and your JSON response, and then, parsing the JSON to compare their values.

 

JSON response example

Expected JSON value (stored in the DataSource test step)

{
	"id": 1111,
	"name": "doggie",
	"photoUrls": [
		"string"
	],
	"tags": [
		{
			"id": 99,
			"name": "string",
			"Additional info": [
				{
					"ad1": "string",
					"ad2": "string"
				}
			]
		}
	],
	"status": "available"
}
{
	"id": 1111,
	"category": {
		"id": 0,
		"name": "string"
	},
	"name": "doggie",
	"photoUrls": [
		"string"
	],
	"tags": [
		{
			"id": 99,
			"name": "string"
		}
	],
	"status": "available"
}

 

 

 

Here's hint: https://smartbear-cc.force.com/portal/KbArticleViewer?name=How-Do-I-Compare-Two-Dynamic-JSON-Respons...


Sonya Mihaljova
Community and Education Specialist

1 REPLY 1
sonya_m
SmartBear Alumni (Retired)

@HimanshuTayal @richie @groovyguy @nmrao @ChrisA 

 

Who will be the first to successfully solve this task?😎


Sonya Mihaljova
Community and Education Specialist

cancel
Showing results for 
Search instead for 
Did you mean: