Skip to content

Unit Test Write-Up

During this module you will enhance one of your previous projects (for example the CRUD CLI from M01 or the prompt harness from M02) with automated unit tests. The goal of this assignment is to practice documenting what you tested and how the new tests fit into the overall Software Testing Life Cycle (STLC).

Objectives

  1. Demonstrate test design skills. Write clear unit tests that verify expected behaviour and edge cases.
  2. Connect testing to the STLC. Show how your planning, execution and reporting follow a structured lifecycle.
  3. Practice bug reporting. If a test fails, create a concise bug report using the format from Lesson 02 – Bug Reporting.
  4. Reflect on process improvements. Explain how adding tests and capturing defects feeds back into your Agile workflow.

Assignment Steps

  1. Choose a prior project. Select code you wrote earlier in the program that does not yet have automated tests.
  2. Plan your tests. Identify at least three functions or components to cover. Briefly describe the expected outcomes and any edge cases.
  3. Write the tests. Use unittest or pytest. Keep each test focused on a single behaviour. Commit your test code to your project repository.
  4. Run the tests. Execute your test suite locally. If a test uncovers a defect, open a bug report following the template in Lesson 02.
  5. Document your work. In this write-up, record the tests you added and link to any bug reports or pull requests where fixes were made.

Suggested Write-Up Format

### Project Tested
Provide a short description of the project and a link to the repository.

### Test Environment
- Python version and test framework used
- Any setup scripts or fixtures

### Test Cases Added
1. **`test_example_function_valid`** – what it verifies
2. **`test_example_function_edge_case`** – what it verifies
3. ...add more as needed

### Results
- Number of tests run and pass/fail summary
- Links to bug reports if failures were discovered

### Lessons Learned
Brief reflection on what was hardest to test, surprises found, and how the tests improve confidence in the code.

Feel free to adapt the sections, but keep the structure organized so reviewers can quickly understand what you covered.

Deliverables

  1. A UNIT_TESTS directory (or similar) in your project repository containing the new test files.
  2. This completed write-up (unit_test_writeup.md) summarizing your approach and results.
  3. Optional screenshots of your test run output or test coverage report.

Submission

Push your tests and the completed write-up to your repository. Open a pull request and mention any unresolved issues or follow-up work. During peer review, teammates will reference your write-up and provide feedback using the checklist from the other assignment in this module.