Compilation error While running Custom Generic Test

Hi,

I am getting the below error while running custom generic test.Can anyone help me out how to fix this error?
'test_Quantity_greater_than_10' is undefined. This can happen when calling a macro that does not exist. Check for typos and/or install package dependencies with "dbt deps".

version: 2
models:
  - name: STG_PRODUCT
    columns:
      - name: quantity
        tests:
          - Quantity_greater_than_10
{%  test Quantity_greater_than_10(model,column_name) %}

with Product as (
select {{column_name}} as quantity
from {{model}}

)
select * from Product
where quantity>10

{% endtest %}

your test name is ‘Quantity_greater_than_10’. in the error test name mentioned is ‘test_Quantity_greater_than_10’

check the name

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

can you pls post your yml fie here where you have configured tests

Hey @saadqureshi45,

Where is your test stored? I tried copying your code and putting it in a file called test_Quantity_greater_than_10.sql in the macros directory and it worked correctly.

You can also put your generic tests (like this one) in the tests/generic directory, as described in the docs on writing custom generic tests.

If you have put this test inside of a different folder path then that could explain your problem.

Regardless, it’s worth noting that instead of making a custom test, you could instead use the dbt_utils.accepted_range test after adding the package to your packages.yml file:

version: 2
models:
  - name: STG_PRODUCT
    columns:
      - name: quantity
        tests:
          - dbt_utils.accepted_range:
              min_value: 10