Blog
Dagster University Presents: Testing with Dagster

Dagster University Presents: Testing with Dagster

Learn best practices for writing Pythonic tests for Dagster.

Dagster University Presents: Testing with Dagster

We are happy to announce a new addition to Dagster University with our new course: Testing with Dagster!

Jump to the Testing with Dagster course page ↗

Learn

Testing is often overlooked in data engineering. However, the only way to properly scale a data platform is to move beyond constant maintenance and troubleshooting issues in production.

In order to build with confidence, you need assurances that your code works as expected before it ships. That means having tests in place to validate new features or ensure changes do not have unintended consequences.

Testing with Dagster is a six-lesson course, each focused on a different aspect of testing. If you've never written tests before, this course provides a structured introduction to test design and an overview of testing in Python. If you're an experienced Python and Dagster user, you’ll find best practices and techniques to streamline your testing suite.

Testing in Dagster

At Dagster, we believe strongly in the power of testing. The only way we can release a new version of Dagster every week is by ensuring everything works as we develop. We want our users to have that same level of confidence in the code they build.

This module covers:

  • The fundamentals of unit testing and writing asset tests in Dagster.
  • Strategies for handling external dependencies in your Dagster deployment while maintaining full control in a testing environment.
  • Best practices for integration testing to ensure your tests mirror real-world production scenarios.
  • Proven Dagster-specific testing tips to help you maintain and optimize your project.

Example: Mocking API calls

@patch("requests.get")
def test_state_population_api_assets_config(mock_get, example_response, api_output):
    mock_response = Mock()
    mock_response.json.return_value = example_response
    mock_response.raise_for_status.return_value = None
    mock_get.return_value = mock_response

    result = dg.materialize(

        assets=[
            lesson_4.state_population_api_resource_config,
            lesson_4.total_population_resource_config,
        ],
        resources={"state_population_resource": lesson_4.StatePopulation()},
        run_config=dg.RunConfig(
            {"state_population_api_resource_config": lesson_4.StateConfig(name="ny")}
        ),
    )
    assert result.success

    assert result.output_for_node("state_population_api_resource_config") == api_output
    assert result.output_for_node("total_population_resource_config") == 9082539

Enroll Today

Like all Dagster University courses, Testing with Dagster is free and available to everyone. Simply sign up at Dagster University to get started. Once enrolled, you can track your progress and learn at your own pace.

Jump to the Testing with Dagster course page ↗

We're always happy to hear your feedback, so please reach out to us! If you have any questions, ask them in the Dagster community Slack (join here!) or start a Github discussion. If you run into any bugs, let us know with a Github issue. And if you're interested in working with us, check out our open roles!

Dagster Newsletter

Get updates delivered to your inbox

Latest writings

The latest news, technologies, and resources from our team.

Annoucing ETL Course with Dagster

July 10, 2025

Annoucing ETL Course with Dagster

Dagster is excited to announce the launch of ETL with Dagster, a comprehensive seven-lesson course. This free course guides you through practical ETL implementation and architectural considerations, from single-file ingestion to full-scale database replication

How Clippd Built Organization-Wide Data Visibility and Saved 8+ Hours Per Week

July 8, 2025

How Clippd Built Organization-Wide Data Visibility and Saved 8+ Hours Per Week

Clippd eliminated 8+ hours of weekly manual data operations and transformed from black-box pipelines to organization-wide data visibility with Dagster. The golf analytics platform now automatically processes data for 200+ college golf programs while democratizing access across their entire team.

From scattered scripts to unified platform: How Dagster powers data decisions for 4.5 million Belgian citizens

July 1, 2025

From scattered scripts to unified platform: How Dagster powers data decisions for 4.5 million Belgian citizens

Belgium's Fédération Wallonie-Bruxelles serves 4.5 million citizens, but their legacy data systems were creating operational chaos—manual processes taking months and zero pipeline visibility. Data engineer Martin Erpicum transformed their platform with Dagster, delivering 2x faster pipeline delivery and shifting from reactive maintenance to proactive data product development.