DBT - Unit Testing

Hi all, I’m using dbt datamocktool package to perform unit testing for my dbt models. In datamocktool, I can provide the input data as CSV on which my model will run and generate output and I can also put output data as expected result. dbt will compare both the expected output and the generated result of the model based on the provided input data.

It is working fine for now. But I want to add aggregation on the generated result so that I can put aggregated expected output as CSV files and dbt will compare both. Is there any way I can do it with the datamocktool package or any other way?

Any help is appreciated!!!

This is an example of datamocktool package unit testing where we can define unit testing for any model with input data as csv files and expected_output as csv files too.
version: 2

models:

  • name: CUSTOMERS
    tests:
    • dbt_datamocktool.unit_test:
      input_mapping:
      source(‘sample_data’, ‘CUSTOMER’): ref(‘dmt_raw_customers’) #csv file
      expected_output: ref(‘dmt_expected_customers’) # csv file

Hi @satyamj999 I believe it is related to this <Issues · mjirv/dbt-datamocktool · GitHub issue> , and when I see that, https://github.com/calogica/dbt-expectations|dbt-expectations package would come into the picture. If you dont want to use additional packages, let’s make your needs happen in dbt singular test now.

Note: @Dat Nguyen originally posted this reply in Slack. It might not have transferred perfectly.