Skip to main content

Command Palette

Search for a command to run...

📌 Schema Validation කියන්නේ මොකක්ද?

Updated
•2 min read•View as Markdown
📌 Schema Validation කියන්නේ මොකක්ද?
H

QA Engineer | Selenium, Playwright, Postman, JMeter | API/UI Testing | Manual & Automation | MERN Stack | ISTQB Trainee | QA Blogger

Schema කියන්නේ basically blueprint එකක් for your data.ඒ කියන්නේ, API එකෙන් එන data එකේ ආකාරය, format එක, මොකක්ද කියලා define කරන එක.API එකක් test කරනකොට, data එක පමණක් නොව, එය data එන structure එකත් බලන්න ඕන. මේකට Schema Validation කියල කියනවා

🔎 උදාහරණයක්

API එකෙන් user profile එකක් එනවා කියලා හිතමු:

{
  "id": 101,
  "name": "Amila",
  "email": "amila@test.com",
  "age": 25
}

👉 Schema එක කියනවා:

  • id → අංකයක් (number) වෙන්න ඕනේ

  • name → අකුරු (string) වෙන්න ඕනේ

  • email → email format එකට ගැලපෙන්න ඕනේ

  • age → අංකයක් වෙන්න ඕනේ


🚨 Error එකක් නම්

API එක "age": "twenty-five" දුන්නොත් → Schema එකට ගැලපෙන්නේ නෑ → Test එක fail වෙනවා.මොකද "age": "twenty-five" යනු string එකක් එක Number එකක් වෙන්න ඕනේ කියලා schema එකේ define කරලා තියෙනවා

👉 හිතාගන්න:
Schema Validation = Data check කරන නීතිය ✅

Schema validation වලට ජනප්‍රිය tools.

  1. Postman

API test කරන්න ඕනෑම කෙනෙක් බහුලවම භාවිත කරන tool එක postmanමේ tool එකෙන්. JavaScript වලින් test case ලියලා response එක schema එකට ගැලපෙනවාද බලන්න පුළුවන්. උදාහරණයක්: "id" කියන field එක number එකක් ද, "name" කියන field එක string එකක් ද කියලා check කරන්න.

  1. Swagger (OpenAPI)

Swagger කියන්නේ API එකක් design කරන්නත්, documentation කරන්නත් යොදාගන්න tool එකක් . Swagger එකෙන් API response එක schema එකට ගැලපෙනවද කියලා validate කරන්න පුළුවන්. API structure එක සහ docs හරිහැටි අවබෝධ කරගන්න Swagger document එක භාවීතා කරයි.

If you have any questions or encounter any issues while implementing these test case strategies, feel free to message me. I'm happy to help and offer further guidance to ensure your testing process is as effective as possible.

More from this blog

How to Begin API Automation: From Postman to Newman

අද මම කතා කරන්න යන්නේ ජනප්‍රිය API Testing tool එකක් වෙන Postman ගැන.හැබැයි අද මගේ Main Topic එක Postman ගැන නෙවෙයි — ඒකේ සහෝදරයා, කියලා කියන්න පුළුවන් Newman ගැන. Postman සහ Newman දෙන්න අතර වෙනස හිතන්න මෙහෙම Postman = Manual testing tool Newman =...

Oct 13, 20254 min read
How to Begin API Automation: From Postman to Newman

Dev Diaries By Hasanka

17 posts

QA Engineer | Selenium, Playwright, Postman, JMeter | API/UI Testing | Manual & Automation | MERN Stack | ISTQB Trainee | QA Blogger