Test Overview
This test simulates running automated tests in a pipeline and verifies that the test report is generated and contains the correct pass/fail summary.
This test simulates running automated tests in a pipeline and verifies that the test report is generated and contains the correct pass/fail summary.
import unittest class SimpleTest(unittest.TestCase): def test_addition(self): self.assertEqual(2 + 3, 5) def test_subtraction(self): self.assertEqual(5 - 3, 2) if __name__ == '__main__': # Run tests and generate report test_suite = unittest.defaultTestLoader.loadTestsFromTestCase(SimpleTest) test_runner = unittest.TextTestRunner(verbosity=2) result = test_runner.run(test_suite) # Simulate pipeline report output print(f"Tests run: {result.testsRun}, Failures: {len(result.failures)}, Errors: {len(result.errors)}")
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test runner starts and loads test cases from SimpleTest class | Test suite contains two test methods: test_addition and test_subtraction | - | PASS |
| 2 | Test runner executes test_addition | Running test_addition which checks if 2 + 3 equals 5 | AssertEqual(2 + 3, 5) passes | PASS |
| 3 | Test runner executes test_subtraction | Running test_subtraction which checks if 5 - 3 equals 2 | AssertEqual(5 - 3, 2) passes | PASS |
| 4 | Test runner completes and prints summary report | Console shows: Tests run: 2, Failures: 0, Errors: 0 | Report correctly shows 2 tests run with zero failures and errors | PASS |