0
0
Testing Fundamentalstesting~10 mins

Defect reporting best practices in Testing Fundamentals - Test Execution Trace

Choose your learning style9 modes available
Test Overview

This test simulates reporting a defect in a software application. It verifies that the defect report contains all necessary information such as steps to reproduce, expected and actual results, severity, and environment details.

Test Code - unittest
Testing Fundamentals
import unittest

class DefectReport:
    def __init__(self, title, steps, expected, actual, severity, environment):
        self.title = title
        self.steps = steps
        self.expected = expected
        self.actual = actual
        self.severity = severity
        self.environment = environment

    def is_complete(self):
        return all([
            bool(self.title.strip()),
            bool(self.steps.strip()),
            bool(self.expected.strip()),
            bool(self.actual.strip()),
            self.severity in ['Low', 'Medium', 'High', 'Critical'],
            bool(self.environment.strip())
        ])

class TestDefectReporting(unittest.TestCase):
    def test_defect_report_completeness(self):
        report = DefectReport(
            title="Login button not working",
            steps="1. Open login page\n2. Enter valid credentials\n3. Click login button",
            expected="User should be logged in and redirected to dashboard",
            actual="Nothing happens when login button is clicked",
            severity="High",
            environment="Windows 11, Chrome 114"
        )
        self.assertTrue(report.is_complete(), "Defect report is incomplete or invalid")

if __name__ == '__main__':
    unittest.main()
Execution Trace - 5 Steps
StepActionSystem StateAssertionResult
1Test startsTest framework initialized, ready to run test_defect_report_completeness-PASS
2Create DefectReport object with all required fields filledDefectReport instance created with title, steps, expected, actual, severity, environment-PASS
3Call is_complete() method to verify all fields are valid and presentMethod checks each field for non-empty and severity is validAll fields are non-empty and severity is one of ['Low', 'Medium', 'High', 'Critical']PASS
4Assert that is_complete() returns TrueAssertion verifies defect report completenessassertTrue(report.is_complete())PASS
5Test ends successfullyTest framework reports test_defect_report_completeness PASSED-PASS
Failure Scenario
Failing Condition: One or more required fields in the defect report are empty or severity is invalid
Execution Trace Quiz - 3 Questions
Test your understanding
What does the test verify about the defect report?
AThat the defect report is submitted to the developer
BThat the defect report contains screenshots
CThat all required fields are filled and severity is valid
DThat the defect report is automatically fixed
Key Result
Always include clear, complete, and valid information in defect reports to help developers understand and fix issues quickly.