Test Fixture

A test fixture supplies the controlled starting state for a test. It can include input rows, explicit schema, session settings, temporary files, and setup or cleanup of dependencies.

Choose small inputs that distinguish the rule being tested: zero from missing, a duplicate from a unique row, or an instant on a time boundary from one outside it. An explicit schema supports empty or all-null input without relying on inference.

A fixed random seed does not make every distributed execution deterministic. Record relevant versions, settings, clocks, and source snapshots. Avoid shared mutable state that lets one test change another testโ€™s starting conditions.

The starting state alone does not determine the right answer. Derive the expected result from the rule being tested, independently of the implementation under test; a fixture can deliver that expected value to the test, but it should not be computed by the code being checked. Verify that a nearby wrong implementation fails. Release temporary resources, while retaining sanitized failure evidence when necessary.

See Testing and Debugging Spark Data Pipelines for worked examples.

References


Discover more from Insightful Data Lab

Subscribe to get the latest posts sent to your email.

Similar Posts

Questions, corrections, or additional insights?

This site uses Akismet to reduce spam. Learn how your comment data is processed.