← Back to libraryQuestion 320 of 468

Positive vs Negative Testing

📌 Definition:

Positive testing verifies the system works as expected with VALID inputs and expected flows ('happy path'); Negative testing verifies the system gracefully HANDLES invalid inputs, errors, and unexpected conditions without crashing.

📖 Detailed Explanation:

POSITIVE (happy-path) testing confirms correct behavior when users do the right thing — valid credentials log in, valid form submits. NEGATIVE testing deliberately provides invalid/boundary/unexpected inputs — wrong password, empty required fields, SQL/script in inputs, huge values, wrong file types — and checks the system responds appropriately (clear errors, no crash, no data corruption, no security hole). Real robustness comes from negative testing; many defects hide in error handling. A balanced suite covers both, and interviewers often ask for negative test ideas for a given field to gauge thoroughness.

🔑 Key Points:
  • Positive = valid inputs / happy path works as expected
  • Negative = invalid/unexpected inputs handled gracefully (no crash)
  • Negative testing finds error-handling and security defects
  • A robust suite covers both; edge/invalid cases hide many bugs
🌍 Real-World Example:

For a login form, positive: valid user/pass → dashboard. Negative: wrong password → clear error; empty fields → validation; SQL in username → no injection; 1000-char input → no crash — probing robustness.

🎯 Scenario-Based Interview Question:

For an email input field, give three negative test cases and explain their value.