# Help with test is undefined error

**URL:** <https://discourse.getdbt.com/t/help-with-test-is-undefined-error/18731>\
**Category:** Help\
**Tags:** testing, dbt-core\
**Created:** [March 20, 2025, 7:47pm UTC](https://discourse.getdbt.com/t/help-with-test-is-undefined-error/18731 "2025-03-20T19:47:19Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jpowell](https://avatars.discourse-cdn.com/v4/letter/j/bbce88/32.png) [@jpowell](https://discourse.getdbt.com/u/jpowell)\
**Post date:** [March 20, 2025, 7:47pm UTC](https://discourse.getdbt.com/t/help-with-test-is-undefined-error/18731/1 "2025-03-20T19:47:19Z")

</div>

## The problem I’m having

I keep getting the following error when I try to run my custom dbt test:

```auto
19:38:44 Completed with 1 error, 0 partial successes, and 0 warnings:
19:38:44  
19:38:44 Compilation Error in test at_least_one_row_mymodelname_ (models/summary/schema.yml)
  'test_at_least_one_row' is undefined. This can happen when calling a macro that does not exist. Check for typos and/or install package dependencies with "dbt deps".

```

## What I’ve already tried

I’ve tried changing the file name and test name.

## schema.yml

```auto
models:
  - name: mymodelname
    tests:
      - at_least_one_row:
          severity: warn

```

##at\_least\_one\_row.sql

```auto
{% test at_least_one_row(model) %}

	
	select 1
	from {{ model }}
	limit 10

{% endtest %}

```

Any thoughts on what might be going on here?  
I’m using dbt-core 1.9 in case that makes a difference.

---

<div class="post-metadata">

**Author:** ![marcelo](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/marcelo/32/6126_2.png) [@marcelo](https://discourse.getdbt.com/u/marcelo)\
**Post date:** [March 20, 2025, 7:57pm UTC](https://discourse.getdbt.com/t/help-with-test-is-undefined-error/18731/2 "2025-03-20T19:57:45Z")

</div>

Hi jpowell, how are you executing this test?

---

<div class="post-metadata">

**Author:** ![jpowell](https://avatars.discourse-cdn.com/v4/letter/j/bbce88/32.png) [@jpowell](https://discourse.getdbt.com/u/jpowell)\
**Post date:** [March 20, 2025, 8:07pm UTC](https://discourse.getdbt.com/t/help-with-test-is-undefined-error/18731/3 "2025-03-20T20:07:03Z")

</div>

Hi @marcelo - I’ve tried the following:

```auto
dbt test --select test_name:at_least_one_row
dbt test --select mymodelname

```

---

<div class="post-metadata">

**Author:** ![marcelo](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/marcelo/32/6126_2.png) [@marcelo](https://discourse.getdbt.com/u/marcelo)\
**Post date:** [March 20, 2025, 8:11pm UTC](https://discourse.getdbt.com/t/help-with-test-is-undefined-error/18731/4 "2025-03-20T20:11:51Z")

</div>

Ok, and where is the test located?

---

<div class="post-metadata">

**Author:** ![jpowell](https://avatars.discourse-cdn.com/v4/letter/j/bbce88/32.png) [@jpowell](https://discourse.getdbt.com/u/jpowell)\
**Post date:** [March 20, 2025, 8:21pm UTC](https://discourse.getdbt.com/t/help-with-test-is-undefined-error/18731/5 "2025-03-20T20:21:59Z")

</div>

The test is located in

```auto
my_project/tests

```

---

<div class="post-metadata">

**Author:** ![marcelo](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/marcelo/32/6126_2.png) [@marcelo](https://discourse.getdbt.com/u/marcelo)\
**Post date:** [March 20, 2025, 8:27pm UTC](https://discourse.getdbt.com/t/help-with-test-is-undefined-error/18731/6 "2025-03-20T20:27:23Z")

</div>

Try moving it to **tests/generic**

"Generic tests are defined in SQL files. Those files can live in two places:

- `tests/generic/`: that is, a special subfolder named `generic` within your [test paths](https://docs.getdbt.com/reference/project-configs/test-paths) (`tests/` by default)
- `macros/`: Why? Generic tests work a lot like macros, and historically, this was the only place they could be defined. If your generic test depends on complex macro logic, you may find it more convenient to define the macros and the generic test in the same file."

Source: [Writing custom generic data tests | dbt Developer Hub](https://docs.getdbt.com/best-practices/writing-custom-generic-tests#generic-tests-with-standard-arguments)

---

<div class="post-metadata">

**Author:** ![jpowell](https://avatars.discourse-cdn.com/v4/letter/j/bbce88/32.png) [@jpowell](https://discourse.getdbt.com/u/jpowell)\
**Post date:** [March 20, 2025, 8:32pm UTC](https://discourse.getdbt.com/t/help-with-test-is-undefined-error/18731/7 "2025-03-20T20:32:06Z")

</div>

Fantastic, this worked. Thank you!

---

<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:** [March 27, 2025, 8:32pm UTC](https://discourse.getdbt.com/t/help-with-test-is-undefined-error/18731/8 "2025-03-27T20:32:34Z")

</div>

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