Definition

Hermetic test

What is a hermetic test?

A hermetic test controls its inputs and dependencies so that unrelated changes outside the test environment cannot alter its result. It can use real components, such as a database, provided the test controls their versions, starting data and interactions.

Does creating a fresh environment make a test hermetic?

A fresh environment prevents some state from leaking between runs. It can still read today’s date or call a shared external service. Trace what the test actually reads. Pin changing dependencies, give the test its own data and supply a controllable clock where time affects the result.

Worked example

Running an overdue-notice test on any day

Give the test its own empty database, add one loan due on Tuesday and advance its clock to Wednesday. Capture the notice using a test mail service. Another test can run beside it with a different loan and clock without affecting which notice is produced.

Try it on your pull request

Choose a change in your repository and tell Cue April what should happen. Review the proposed checks before they run.

Try Cue April on your repository