# DBT - Unit Testing

**URL:** <https://discourse.getdbt.com/t/dbt-unit-testing/8165>\
**Category:** Help\
**Tags:** testing, snowflake, dbt-core\
**Created:** [May 5, 2023, 11:43am UTC](https://discourse.getdbt.com/t/dbt-unit-testing/8165 "2023-05-05T11:43:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![satyamj933](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/satyamj933/32/2320_2.png) [@satyamj933](https://discourse.getdbt.com/u/satyamj933)\
**Post date:** [May 5, 2023, 11:43am UTC](https://discourse.getdbt.com/t/dbt-unit-testing/8165/1 "2023-05-05T11:43:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![a\_slack\_user](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/a_slack_user/32/1629_2.png) [@a\_slack\_user](https://discourse.getdbt.com/u/a_slack_user)\
**Post date:** [May 5, 2023, 2:49pm UTC](https://discourse.getdbt.com/t/dbt-unit-testing/8165/2 "2023-05-05T14:49:22Z")

</div>

Hi @satyamj999 I believe it is related to this \<[Issues · mjirv/dbt-datamocktool · GitHub](https://github.com/mjirv/dbt-datamocktool/issues/7%7Copen) issue\> , and when I see that, [https://github.com/calogica/dbt-expectations|dbt-expectations](https://github.com/calogica/dbt-expectations%7Cdbt-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](https://getdbt.slack.com/archives/CBSQTAPLG/p1683298154821939?thread_ts=1683287043.395639&cid=CBSQTAPLG). It might not have transferred perfectly.
