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

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Tags (1)
1 REPLY 1
Highlighted
Community Manager

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

@HimanshuTayal @richie @msiadak @nmrao @ChrisA 

 

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


Sonya Mihaljova
Community and Education Specialist

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors