Example-Based Tests
Given X, expect Y. The fundamental behavioral sensor.
Fundamentally different from coverage: coverage says “this code executed.” A behavioral assertion says “this code produced the right result.” That is a massive distinction.
The weakness
Example-based tests are only as good as the examples chosen. They test what the author thought to test. Mutation testing and metamorphic testing exist to find the gaps.
Sensor properties
| Property | Value |
|---|---|
| Oracle strength | High — assertion failure is definitive |
| Independence | Low — same author writes code and tests |
| Scope | Function-level |
| Feedback latency | Seconds |
| Actionability | Guiding — shows expected vs actual |
| Type | Predictive |
What it cannot detect
Missing behavior, untested edge cases, and integration failures that emerge only when components are connected.