Files
Tirsvad 5708c4ef55
TirSystem/git-workflows: OpenGrep / opengrep (push) Skipped
TirSystem/git-workflows: Publish wiki / publish-wiki (push) Skipped
TirSystem/git-workflows: Release / release (push) Skipped
TirSystem/git-workflows: Sync GitHub mirror metadata / sync-metadata (push) Skipped
TirSystem/git-workflows: Publish accepted milestones / publish (push) Skipped
TirSystem/git-workflows: Validate / validate (push) Skipped
TirSystem/git-workflows: Release / release (pull_request) Successful in 27s
TirSystem/git-workflows: Validate / validate (pull_request) Successful in 45s
TirSystem/git-workflows: OpenGrep / opengrep (pull_request) Successful in 2m16s
Add project wiki in English, Danish and Malay
2026-11-15 10:06:00 +08:00

46 lines
1.1 KiB
Markdown

# Testing
🌐 **English** · [Dansk](Testing-da) · [Bahasa Melayu](Testing-ms)
The tests use `unittest` from the Python standard library, so nothing extra
needs to be installed. Install the project first (`pip install -e .`, see
[Install](Install)).
## Run the tests
From the repository root:
```bash
python -m unittest
```
To see each test's name and result:
```bash
python -m unittest -v tests.test_calculator
```
## What is tested
`tests/test_calculator.py` tests `bill_per_person` in `calculator.py`:
| Test | Checks |
| --- | --- |
| `test_course_example` | 124.56 with a 12% tip for 7 people gives 19.93 |
| `test_tip_split_five_ways` | 150 with a 12% tip for 5 people gives 33.6 |
| `test_zero_people_raises` | 0 people raises `ValueError` |
The console in `main.py` is not covered by a test; it only reads input and
prints.
## Add a test
Add a method to `BillPerPersonTests`. The name must start with `test_`:
```python
def test_no_tip(self):
self.assertEqual(bill_per_person(100, 0, 4), 25.0)
```
Run `python -m unittest` again and check that it passes.