trivial-inputs
A test passes the code it tests only default values.
- Group
- Tests
- Runs
- On by default
- Level
- warning
- Reads
- Tests
- Fix
- None: which values the test should pass is the author's choice
- Defends
- Fidelity: when the code is broken, the test fails.
Why
Every constant the test passes to the code it tests is its type's zero value: zero, false, an empty string or collection, or a missing value. Code that ignores its input entirely passes such a test. A test that also passes a value it computed is not reported.
The fix, as Ur suggests it: pass values other than the defaults.
For agents
Pass the code under test values other than its types' defaults, such as 7 or "apple" rather than 0 or "", so a test fails when the code ignores its input.
Example
shop/pricing.pydef apply_discount(price, percent):
return price - price * percent / 100
tests/test_pricing.pyfrom shop.pricing import apply_discount
def test_applies_discount():
assert apply_discount(0, 0) == 0
$ ur lint --rule trivial-inputs
warning[trivial-inputs]: every value test `test_applies_discount` passes to the code it tests is a default, so ignoring its input passes too
--> ./tests/test_pricing.py:5:12 test `test_applies_discount`
= step 1: ./tests/test_pricing.py:5:27 a default value
= step 2: ./tests/test_pricing.py:5:30 a default value
= hint: pass values other than the defaults
= see: Choosing Values for Robust Tests, Google Testing Blog (2026-06-04), https://testing.googleblog.com/2026/06/choosing-values-for-robust-tests.html
0 clone classes and 1 test finding in 2 files
Source
Choosing Values for Robust Tests, Google Testing Blog (2026-06-04).