- Published on
Advent of Pull Requests Best Practice - Day 23
- Authors
- Name
- Nico Prananta
- @2co_p
From my team experience, the linchpin of a software project is the incorporation of automated tests. Tests are vital to safeguard against future application breakdowns as code undergoes addition, deletion, or modification. They become even more crucial as team members transition in and out. Without tests as a safety net, the risk of introducing breaking changes into production increases significantly.
Here's a guide to handle test coverage during PR reviews:
- Confirming Test Inclusion: Initially, verify whether the PR incorporates new or updated tests pertinent to the code changes. For bug fixes, the PR should include tests aimed at the specific bug, confirming its resolution.
- Evaluating Test Relevance and Sufficiency: Assess if the tests sufficiently cover the new or altered code. For example, with the introduction of a new function, are there tests evaluating its outputs under varying inputs? In bug fixes, check if the tests demonstrate the problem prior to the fix and affirm its effectiveness post-fix.
- Scrutinizing Test Scenarios: Review the test scenarios to confirm they are realistic and all-encompassing. They should address standard use cases, extreme scenarios, and potential error situations. For instance, in a PR addressing a form submission bug, the tests should encompass a range of input combinations, including extremes like blank entries or unexpected characters.
- Ensuring Regression Tests: For bug fixes, regression tests are essential. These tests are designed to prevent the recurrence of the same bug, reinforcing confidence that the issue is thoroughly resolved.
As Kent C. Dodds advises, remember to write tests, not too many, mostly integration.
📖 Early Bird Offer
Need more insights like this? Jump on our early bird offer and grab your copy for 40% less! This deal is flying off the shelves, so hurry! 🎉