Defect classification (severity, priority) in Testing Fundamentals - Full Explanation
Imagine a busy restaurant kitchen where some problems happen: a broken oven (stops cooking), a missing spoon, or a slightly messy counter. The broken oven is very serious and needs immediate fixing, while the missing spoon is less serious but might be needed soon. The kitchen manager decides which problem to fix first based on how it affects cooking and serving customers.
┌─────────────┐ ┌─────────────┐
│ Defect │──────▶│ Severity │
│ Reported │ │ (Impact on │
└─────────────┘ │ software) │
└─────┬───────┘
│
▼
┌─────────────┐
│ Priority │
│ (Fix order) │
└─────────────┘class Defect: def __init__(self, description, severity, priority): self.description = description self.severity = severity # e.g., 'High', 'Medium', 'Low' self.priority = priority # e.g., 'Urgent', 'Normal', 'Low' def info(self): return f"Defect: {self.description}\nSeverity: {self.severity}\nPriority: {self.priority}" # Example defects bug1 = Defect("App crashes on login", "High", "Urgent") bug2 = Defect("Typo in help text", "Low", "Low") print(bug1.info()) print(bug2.info())
Practice
What does severity indicate in defect classification?
Solution
Step 1: Understand the meaning of severity
Severity measures the impact or seriousness of a defect on the system or user.Step 2: Differentiate severity from priority
Priority is about scheduling the fix, not the defect's impact.Final Answer:
How serious or harmful the defect is -> Option AQuick Check:
Severity = seriousness [OK]
- Confusing severity with priority
- Thinking severity means who found the bug
- Assuming severity counts defect occurrences
Which of the following is the correct way to classify a defect with high severity and low priority?
Solution
Step 1: Understand high severity
High severity means the defect causes major problems or failures.Step 2: Understand low priority
Low priority means the defect fix can be delayed or scheduled later.Final Answer:
A defect that causes major system failure but can be fixed later -> Option BQuick Check:
High severity + low priority = serious but delayed fix [OK]
- Assuming high severity always means high priority
- Mixing up severity and priority meanings
- Ignoring the priority when severity is high
Consider this defect list with severity and priority:defects = [{'id':1, 'severity':'High', 'priority':'Low'}, {'id':2, 'severity':'Low', 'priority':'High'}, {'id':3, 'severity':'Medium', 'priority':'Medium'}]
Which defect should be fixed first based on priority?
Solution
Step 1: Check priority values of each defect
Defect 1 has priority Low, Defect 2 has priority High, Defect 3 has priority Medium.Step 2: Determine which priority is highest
High priority means fix first, so Defect 2 should be fixed first.Final Answer:
Defect with id 2 -> Option AQuick Check:
Highest priority = fix first [OK]
- Choosing based on severity instead of priority
- Assuming Medium priority is higher than High
- Ignoring priority values
Find the error in this defect classification code snippet:
def classify_defect(severity, priority):
if severity == 'High' and priority == 'High'
return 'Fix Immediately'
else:
return 'Schedule Fix'Solution
Step 1: Check syntax of if statement
The if statement lacks a colon at the end of the condition line.Step 2: Verify other parts of the function
Return statements and else block indentation are correct.Final Answer:
Missing colon after if condition -> Option CQuick Check:
if condition must end with ':' [OK]
- Forgetting colon after if condition
- Misplacing indentation in else block
- Assuming missing return statement
You have a list of defects with severity and priority:defects = [{'id':101, 'severity':'Medium', 'priority':'High'}, {'id':102, 'severity':'High', 'priority':'Low'}, {'id':103, 'severity':'Low', 'priority':'Medium'}]
Write a Python expression using dictionary comprehension to create a dictionary mapping defect id to 'Fix Immediately' if priority is High, else 'Fix Later'.
Solution
Step 1: Understand dictionary comprehension syntax
It uses {key: value for item in iterable} with conditional expressions inside value.Step 2: Check conditional expression correctness
{d['id']: ('Fix Immediately' if d['priority'] == 'High' else 'Fix Later') for d in defects} correctly uses parentheses and '==' for comparison inside the expression.Final Answer:
{d['id']: ('Fix Immediately' if d['priority'] == 'High' else 'Fix Later') for d in defects} -> Option DQuick Check:
Correct dict comprehension with conditional [OK]
- Using single '=' instead of '==' in condition
- Missing parentheses around conditional expression
- Placing else outside parentheses
Ready to prove it?
Pass the test and this pattern moves unknown
