# Customizing dbt Test Output Name

**URL:** <https://discourse.getdbt.com/t/customizing-dbt-test-output-name/5550>\
**Category:** Help\
**Tags:** testing\
**Created:** [December 11, 2022, 7:45am UTC](https://discourse.getdbt.com/t/customizing-dbt-test-output-name/5550 "2022-12-11T07:45:20Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![MrsT](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/mrst/32/1446_2.png) [@MrsT](https://discourse.getdbt.com/u/MrsT)\
**Post date:** [December 11, 2022, 7:45am UTC](https://discourse.getdbt.com/t/customizing-dbt-test-output-name/5550/1 "2022-12-11T07:45:20Z")

</div>

Is there a way to customize the auto-generated dbt test name? By default I see it’s test\_name, model name, properties… Can I customize the name myself?

 ![image](https://us1.discourse-cdn.com/flex020/uploads/getdbt/original/2X/f/ffa89986916a101d0bbaf590ecd214ef8577b0b1.png)

---

<div class="post-metadata">

**Author:** ![obar1](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/obar1/32/1221_2.png) [@obar1](https://discourse.getdbt.com/u/obar1)\
**Post date:** [December 11, 2022, 8:17am UTC](https://discourse.getdbt.com/t/customizing-dbt-test-output-name/5550/2 "2022-12-11T08:17:11Z")

</div>

Curious… customize how given those examples ?

---

<div class="post-metadata">

**Author:** ![MrsT](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/mrst/32/1446_2.png) [@MrsT](https://discourse.getdbt.com/u/MrsT)\
**Post date:** [December 11, 2022, 5:21pm UTC](https://discourse.getdbt.com/t/customizing-dbt-test-output-name/5550/3 "2022-12-11T17:21:10Z")

</div>

Let’s say for the first one, I just wanted to call it “is\_unique” (for example, if I knew it would be the absolutely ONLY place I was calling this test)

(This is for a case where the generated name is extremely long since there are a lot of properties past in. I’d like to truncate the name to make the output easier to parse)

---

<div class="post-metadata">

**Author:** ![joellabes](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/joellabes/32/3980_2.png) [@joellabes](https://discourse.getdbt.com/u/joellabes)\
**Post date:** [December 12, 2022, 9:05am UTC](https://discourse.getdbt.com/t/customizing-dbt-test-output-name/5550/4 "2022-12-12T09:05:26Z")

</div>

You can do this by using the `name` property on the test: [https://docs.getdbt.com/reference/resource-properties/data-tests#custom-data-test-name](https://docs.getdbt.com/reference/resource-properties/data-tests#custom-data-test-name)

---

<div class="post-metadata">

**Author:** ![MrsT](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/mrst/32/1446_2.png) [@MrsT](https://discourse.getdbt.com/u/MrsT)\
**Post date:** [December 12, 2022, 9:11am UTC](https://discourse.getdbt.com/t/customizing-dbt-test-output-name/5550/5 "2022-12-12T09:11:28Z")

</div>

Does that imply that I can use the list\_unexpected\_properties test, renaming it to contract\_unexpected\_properties in this particular test? That doesn’t seem to work here. Am I misunderstanding something?

![image](https://us1.discourse-cdn.com/flex020/uploads/getdbt/original/2X/e/e174f014773e61d3e07713722ec3dd6559e5cc37.png)

I get a compilation error that the ‘test\_contract\_unexpected\_properties’ is undefined

---

<div class="post-metadata">

**Author:** ![joellabes](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/joellabes/32/3980_2.png) [@joellabes](https://discourse.getdbt.com/u/joellabes)\
**Post date:** [December 12, 2022, 9:16am UTC](https://discourse.getdbt.com/t/customizing-dbt-test-output-name/5550/6 "2022-12-12T09:16:46Z")

</div>

This is the [example code from the docs](https://docs.getdbt.com/reference/resource-properties/data-tests#custom-data-test-name):

```yaml
version: 2

models:
  - name: orders
    columns:
      - name: status
        tests:
          - accepted_values:
              name: unexpected_order_status_today
              values: ['placed', 'shipped', 'completed', 'returned']
              config:
                where: "order_date = current_date"

```

In your case, you would do something like:

```auto
models: 
  - name: contract_schema
    columns: 
      - name: key
        tests:
          - list_unexpected_properties:
              name: contract_unexpected_properties
              value_set: [caseId, billingMethod, ...]

```

In the code you provided, you’re trying to attach two tests to the `key` column, a `contract_unexpected_properties` test with no arguments (like the built-in `unique` or `not_null` tests) and a `list_unexpected_properties` test which has a `value_set` argument.

---

<div class="post-metadata">

**Author:** ![MrsT](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/mrst/32/1446_2.png) [@MrsT](https://discourse.getdbt.com/u/MrsT)\
**Post date:** [December 12, 2022, 9:21am UTC](https://discourse.getdbt.com/t/customizing-dbt-test-output-name/5550/7 "2022-12-12T09:21:13Z")

</div>

That is beautiful and exactly what I’m looking for. Thank you!

For my own understanding, I don’t see the exact sample code you pasted in the docs you linked. Can you help me find that? It would have made things much clearer for me initially.

---

<div class="post-metadata">

**Author:** ![joellabes](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/joellabes/32/3980_2.png) [@joellabes](https://discourse.getdbt.com/u/joellabes)\
**Post date:** [December 12, 2022, 9:26am UTC](https://discourse.getdbt.com/t/customizing-dbt-test-output-name/5550/8 "2022-12-12T09:26:31Z")

</div>

It’s towards the bottom of the page (screenshot below); if you can’t see it, check which version of the docs you’re using (in my screenshot I have v1.3 selected). If you are looking at an old version then it might not show up; I don’t remember when this functionality was added!

 ![image](https://us1.discourse-cdn.com/flex020/uploads/getdbt/original/2X/0/0fcbf064656aac6e19d3f17c0a5918a6d903ef1c.jpeg)

---

<div class="post-metadata">

**Author:** ![MrsT](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/mrst/32/1446_2.png) [@MrsT](https://discourse.getdbt.com/u/MrsT)\
**Post date:** [December 12, 2022, 9:29am UTC](https://discourse.getdbt.com/t/customizing-dbt-test-output-name/5550/9 "2022-12-12T09:29:52Z")

</div>

Changing the version did it for me. Good to know that it was on v1.0 by default and I didn’t easily see how to change it. Hopefully, this makes things much clearer going forward.

Thanks again for your help!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/getdbt/original/1X/a7a7ca1fe379aaf90952b0e13118a817babcd14f.png) [@system](https://discourse.getdbt.com/u/system)\
**Post date:** [December 19, 2022, 9:30am UTC](https://discourse.getdbt.com/t/customizing-dbt-test-output-name/5550/10 "2022-12-19T09:30:34Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
