RBENREJEB@RBR-OS:/OPT/DATAFORM-INTELLIJ-PLUGIN/FEATURES/UNIT-TESTS$ CAT README
FEATURES
Unit tests
Google Cloud Dataform Plugin for IntelliJ · Features
Dataform unit tests check the output of a table or view against fixed input data. The plugin creates them for you, helps you write them and runs them in BigQuery.
Create a test
Right-click a SQLX or JavaScript file that defines a table or view, in the editor or the Project view, and choose Create Dataform Test. When the file defines several actions, the plugin asks which ones to test.
The test is written to definitions/tests/test_<action>.sqlx, with an input block for each table
the action reads and the expected output, pre-filled from the columns known for each table. A table
whose columns are not known yet gets a placeholder row. Existing test files are left untouched.
Test files have their own icon in the Project view.
Write the test
- Completion suggests the inputs of the tested action and their columns.
Ctrl+Clickon the tested dataset or an input jumps to its definition.- In an input block or the expected output, the Generate SELECT from schema of … intention
(
Alt+Enter), named after the table, writes aSELECTlisting every column of the table with a placeholder value of its type, includingSTRUCTand repeated columns. - Renaming a column of the tested action or of an input table also renames it in the test. See Column refactoring.
The Test view of the split editor shows the compiled Test query, the tested action’s query run on your inputs, and the Expected output. Run test query runs either of them in BigQuery, to see what the test compares.
Run tests
Run a test with Run test in the editor toolbar or from the gutter of its file, or create a
Dataform Unit Tests run configuration to run a file, a directory or all the tests of the
project. The plugin compiles the project, runs the tests in BigQuery and compares the rows the way
dataform test does.
Results appear in the IDE test runner. A failed test names the row and column that differ, or the row count or columns that do not match: For row 0 and column “lifetime_value”: expected “650”, but saw “600”. Click to see difference opens the expected and actual rows side by side.
Tests run in the GCP project of the active repository, so they need the Google Cloud sign-in and a repository selected in the Dataform panel.