cancel
Showing results for 
Search instead for 
Did you mean: 

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

Highlighted
Community Manager

[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

Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today
Tags (1)
1 REPLY 1
Highlighted
Community Manager

@HimanshuTayal @richie @msiadak @nmrao @ChrisA 

 

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


Sonya Mihaljova
Community and Education Specialist

Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today
New Here?
Join us and watch the welcome video:
Announcements
TechCorner Leaderboard
Want a fun and easy way to learn ReadyAPI and show off your skills? Try solving weekly TechCorner challenges and get into the Leaderboard!


Challenge Status

Get a full Raw JMS request

Participate!

Compare an expected JSON value and actual response in Events

Participate!

Fetch value/data from JSON response using Groovy Script

See replies!

Get data from Petstore and add it to Excel sheets

Participate!
Top Kudoed Authors