The pyramid

Not all tests are worth the same

PawWalk has real logic worth testing: the distance math from module 11 (turning GPS fixes into meters and kilometers), the price formatting from module 3, the offline sync queue from module 14. But not every test should look the same, or cost the same to run. The testing pyramid is a shape, not a rulebook: a wide base of cheap tests, a narrower middle, a small tip.

At the base sit JVM unit tests β€” plain JUnit, no Android device or emulator involved, just the JVM on your laptop. They test pure logic: given this input, is the output correct? A function that turns 1,842 meters into "1.84 km" doesn't need a phone to verify β€” it needs a value and an assertion. These run in milliseconds and there should be hundreds of them.

In the middle, Robolectric simulates Android framework classes (Context, SharedPreferences, resources) directly on the JVM, no emulator required. It's for code that touches the framework but doesn't need to be pixel-perfect β€” a repository that reads a string resource, a class that checks ConnectivityManager.

At the top, a handful of instrumented tests β€” Compose UI tests that actually render a screen and click through it. These are the slowest and priciest to run, so the pyramid keeps them few and reserved for flows where only "does the real UI behave" is a good enough question.

Speed and determinism drive the shape: a test suite that's mostly UI tests is slow to run and flaky to trust, so most of the confidence should come from the fast, deterministic base.