Skip to content

Latest commit

 

History

History
37 lines (27 loc) · 1.87 KB

File metadata and controls

37 lines (27 loc) · 1.87 KB

import PyObject from 'components/PyObject';

Testing solids and pipelines

Let's go back to our first solid and pipeline hello_cereal.py.

It wouldn't be complete without some tests to ensure they're working as expected. We'll use to test our pipeline, as well as to test our solid in isolation.

These functions synchronously execute a pipeline or solid and return results objects (the and ) whose methods let us investigate, in detail, the success or failure of execution, the outputs produced by solids, and (as we'll see later) other events associated with execution.

file:/dagster_examples/intro_tutorial/basics/e04_quality/hello_cereal_with_tests.py
lines:32-43

Now you can use pytest, or your test runner of choice, to run unit tests as you develop your data applications.

$ pytest hello_cereal_with_tests.py

Note: by convention, pytest tests are typically kept in separate files prefixed with test_. We've put them in the same file just to simplify the tutorial code.

Obviously, in production we'll often execute pipelines in a parallel, streaming way that doesn't admit this kind of API, which is intended to enable local tests like this.

Dagster is written to make testing easy in a domain where it has historically been very difficult. Throughout the rest of this tutorial, we'll explore the writing of unit tests for each piece of the framework as we learn about it. You can learn more about Testing in Dagster by reading Testing Guide.