PowerUser Plugin for dbt

Generate dbt Unit Tests in the Documentation Editor, Next to Your Docs and Data Tests

Click plus next to Unit Tests in the Documentation Editor and Altimate Code proposes dbt unit test scenarios with full YAML, added only after you approve.

Generate dbt unit tests in the Documentation Editor, next to your docs and data tests
TL;DR
  • What it is. The Documentation Editor in the PowerUser Plugin for dbt, where you write docs, add data tests and now add model-level unit tests. The AI drafts need a free Altimate API key.
  • Who it is for. Analytics engineers who know a model needs tests and docs, and never find the hour to write the YAML.
  • What you get. Unit test scenarios with full input and expected-output YAML, written to your schema file only after you pick one.

Data tests check the rows in a table. They catch a null or a duplicate key after the model builds. They cannot prove that the logic behind the table is right. A dbt unit test does that. You give the model fixed input rows and state the exact output you expect.

Data testUnit test
RunsAfter the model buildsBefore the model builds
ReadsThe rows in the tableFixed input rows you write
FindsBad data, such as a null keyWrong logic, such as a split payment summed twice
Exampleunique, not_nulltest_orders_split_payment

Open the Documentation Editor From the PowerUser Icon

With a model open, click the PowerUser Plugin for dbt icon in the side bar and open the Documentation Editor. It holds the model description, the model's data tests and unit tests, and one row per column. Generate descriptions for the model or for a single column. Then rewrite any description with Regenerate, Make it shorter, Make it longer, Make it fun or Generate for business user.

The Regenerate Documentation picker for column customer_id, offering Regenerate, Make it shorter, Make it longer, Make it fun and Generate for business user, above the Documentation Editor row for customer_id with Data Tests not_null, relationships, accepted_values, unique and Custom Test.

Add Data Tests in a Few Clicks

Click the plus sign next to a column's data tests to add a generic test. The editor offers four:

  • unique, so no value repeats in the column.
  • not_null, so every row has a value.
  • accepted_values, so the column holds only the values you type.
  • relationships, so each value exists in another model.

For accepted values, type the allowed values and click Add. For any other rule, click Custom Test. An Altimate Code session writes the test and adds nothing until you approve it. The tests guide lists every generic test the editor supports.

Let Altimate Code Propose Unit Test Scenarios

Click the plus sign next to Unit Tests at model level. Altimate Code reads the model and proposes scenarios, each with the full YAML for its inputs and expected output. On the orders model it proposed four:

  1. A single payment method.
  2. A split payment across two methods on one order.
  3. Several orders, to check that grouping keeps them apart.
  4. An order with no payments, the LEFT JOIN edge case.

The Altimate Code chat titled Unit tests proposal for orders dbt model, listing four proposed unit test scenarios, above the Documentation Editor for Model: orders with its Data Tests and Unit Tests rows.

You review the YAML and reply with the scenario you want. Altimate Code adds test_orders_split_payment to models/schema.yml, then runs the models to confirm the test passes. From then on, dbt checks that logic on every run. The unit test then fails if someone changes how the model sums payments. It fails before the change reaches a dashboard.

The chat confirms Adding the split payment unit test to models/schema.yml, the Unit Tests row now shows test_orders_split_payment, and a side panel shows its YAML with two payment rows for order 2, credit_card 10 and gift_card 5.

Spotlight 3 video, dbt docs, data tests and unit tests in one editor

Need descriptions for every column at once? Use bulk documentation generation.

Install the dbt VS Code extension

Frequently Asked Questions

Install the dbt VS Code Extension. Free to Start.

Power User for dbt is an open source VS Code extension that adds column lineage, autocomplete, AI docs, query previews and health checks to your dbt project.

The Altimate platform: team spend by warehouse, dbt column lineage and an Altimate Code session recap