Define a behavior rather than a line of code
For a shipping function, a useful behavior is that a cart at the free-shipping threshold receives no shipping charge. The test supplies the cart value and asserts the exact result. Merely executing every line does not establish that the charge matches the business rule.
Choose the public interface that expresses the behavior clearly. Testing private helper calls can make harmless refactoring break many tests. A behavior-focused check should still pass when the implementation changes internally while preserving the same externally observable result for the controlled input under examination.
Control dependencies deliberately
Replace a clock or remote price provider when the rule needs a stable value. Keep the replacement small and explicit. A test that contacts a live provider can fail because of availability or data changes even when the local calculation remains correct for the expected inputs.
Do not mock the function you intend to test. If every meaningful collaborator is replaced, the check may only confirm that the mocks return their configured values. Use a separate integration check when the risk concerns real serialization, database queries, or communication between application components.
Use boundaries to make checks valuable
Include values immediately below, at, and above a rule boundary. Add an invalid input if the interface defines its handling. These examples make an off-by-one comparison visible and communicate the rule more effectively than several ordinary inputs that all exercise the same straightforward path.
Give each test a name that states the condition and expected outcome. Keep setup readable and reset changed state after the run. When a failure occurs, an engineer should understand which behavior changed without first reconstructing a large fixture or inspecting every private implementation detail.
Working sheet
| Input | Expected result | Reason |
|---|---|---|
| Below threshold | Shipping charged | Lower boundary |
| At threshold | Free shipping | Equality rule |
| Above threshold | Free shipping | Upper boundary |
| Invalid cart value | Defined error | Input contract |
Questions about what is a unit test?
Does unit mean one method?
Not necessarily. Choose a small behavior boundary that produces clear, isolated feedback.
Does coverage prove a test is useful?
No. Coverage shows execution. Assertions and defect detection establish what the check can verify.
How should I use the working sheet?
Download the CSV and replace the sample rows with evidence from your repository. Record a clear acceptance check and an owner for each item. Keep unresolved assumptions visible rather than treating the example as a completed assessment.
Sources and further reading
Examples are illustrative. They are not customer results, security guarantees, or a substitute for checking the documentation for your installed version.
