Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

define generic tests in configured tests-paths directory #3250

Closed
kwigley opened this issue Apr 12, 2021 · 1 comment · Fixed by #4052
Closed

define generic tests in configured tests-paths directory #3250

kwigley opened this issue Apr 12, 2021 · 1 comment · Fixed by #4052
Assignees
Labels
1.0.0 Issues related to the 1.0.0 release of dbt dbt tests Issues related to built-in dbt testing functionality enhancement New feature or request

Comments

@kwigley
Copy link
Contributor

kwigley commented Apr 12, 2021

Add ability for all tests to be defined in the same subdirectory.

@kwigley kwigley added enhancement New feature or request dbt tests Issues related to built-in dbt testing functionality labels Apr 12, 2021
@kwigley kwigley changed the title define tests in test/ define tests in configured tests-paths Apr 12, 2021
@kwigley kwigley changed the title define tests in configured tests-paths define tests in configured tests-paths directory Apr 12, 2021
@jtcohen6 jtcohen6 added this to the Margaret Mead milestone Apr 13, 2021
@jtcohen6 jtcohen6 removed this from the Margaret Mead milestone Jun 2, 2021
@jtcohen6 jtcohen6 added the 1.0.0 Issues related to the 1.0.0 release of dbt label Jun 24, 2021
@jtcohen6
Copy link
Contributor

jtcohen6 commented Oct 6, 2021

Big idea here: Allow users to define test blocks inside the directories defined by test-paths.

Functionally, these test blocks work a lot like macros—in fact, a test block named my_cool_test will be converted internally into a macro named test_my_cool_test. That used to be explicit, user-exposed functionality; we've since made it a thing that happens behind the scenes.

To make this happen, I imagine we'd need to run the MacroParser over both macro_paths and test_paths:
https://github.com/dbt-labs/dbt/blob/6fc64f0d3b8a9e0c8c7566d3a22aef75d8ed8b3c/core/dbt/parser/read_files.py#L123-L125

That is, we need to parse generic tests (like all macros) before parsing other file types, in order to construct the contexts needed to parse those other resources. I definitely defer to @gshank's judgment here.

I'm not so concerned about reading the contents of test-paths twice, since we don't see many projects with tons of custom singular tests—it's not a recommended pattern, since they're really meant as one-offs—but I bet we could come up with a slicker, more performant way to avoid twice-reading in the future.

@jtcohen6 jtcohen6 changed the title define tests in configured tests-paths directory define generic tests in configured tests-paths directory Oct 6, 2021
@emmyoop emmyoop self-assigned this Oct 7, 2021
@emmyoop emmyoop mentioned this issue Oct 13, 2021
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.0.0 Issues related to the 1.0.0 release of dbt dbt tests Issues related to built-in dbt testing functionality enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants