Skip to content

Files

unit_tests

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Nov 23, 2022
Dec 12, 2022
Jun 23, 2023
Nov 23, 2022
Nov 4, 2023
Nov 23, 2022
Jul 30, 2023
Apr 15, 2023
Mar 11, 2023
Apr 15, 2023
Mar 11, 2023
Mar 11, 2023
Apr 15, 2023
Jun 5, 2024
Jun 5, 2024
Jun 23, 2023
Apr 15, 2023

Unit Testing

The dbt-ga4 package treats each model and macro as a 'unit' of code. If we fix the input to each unit, we can test that we received the expected output. To do this, we use the pytest framework as described here:

You'll need to install pytest, pytest-dotenv and create a .env file with a BIGQUERY_PROJECT key containing the name of your BigQuery project. An 'oauth' connection method is assumed for local development.

Installing pytest & pytest-dotenv can be done using the requirements.txt file. Navigate to the unit_tests folder and run

pip install -r requirements.txt

To run the folder's suite of tests, navigate to the unit_tests folder in the command line and run:

python -m pytest .

To run a specific test:

python -m pytest path/to/test.py