-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Adding logic to TestSelector to remove unit tests if they are in excluded_resource_types #10657
Adding logic to TestSelector to remove unit tests if they are in excluded_resource_types #10657
Conversation
Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: Matthew.Cooper.
|
Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide. |
…uded_resource_types
38bf328
to
3e19e62
Compare
Thanks for your pull request, and welcome to our community! We require contributors to sign our Contributor License Agreement and we don't seem to have your signature on file. Check out this article for more information on why we have a CLA. In order for us to review and merge your code, please submit the Individual Contributor License Agreement form attached above above. If you have questions about the CLA, or if you believe you've received this message in error, please reach out through a comment on this PR. CLA has not been signed by users: @TowardOliver |
Thanks for your pull request, and welcome to our community! We require contributors to sign our Contributor License Agreement and we don't seem to have your signature on file. Check out this article for more information on why we have a CLA. In order for us to review and merge your code, please submit the Individual Contributor License Agreement form attached above above. If you have questions about the CLA, or if you believe you've received this message in error, please reach out through a comment on this PR. CLA has not been signed by users: @TowardOliver |
I've just signed the CLA, so hopefully this now proceeds. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #10657 +/- ##
==========================================
- Coverage 88.94% 88.89% -0.06%
==========================================
Files 180 180
Lines 22778 22783 +5
==========================================
- Hits 20260 20252 -8
- Misses 2518 2531 +13
Flags with carried forward coverage won't be shown. Click here to find out more.
|
# Exclude unit tests with environment variable for test command | ||
results = run_dbt(["test", "--select", "my_model"], expect_pass=True) | ||
assert len(results) == 0 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice @TowardOliver !
Could you do something similar just a little earlier in the file for when dbt test --exclude-resource-types unit_test
? You can copy-paste-modify the section that starts with "# Run build command but specify no unit tests".
@cla-bot check |
The cla-bot has been summoned, and re-checked this pull request! |
I've added the specific unit test you mentioned @dbeatty10 to test Although I see that you've raised your own PR here: #10706 |
@TowardOliver Your PR provided the map of everything that needed to be done, plus the unit tests to verify it. 🤩 That empowered me to see how we could solve this though a refactor. Thank you! #10706 includes your commits and also lists you as co-author to preserve the credit for your contributions. |
Thanks again for proposing this feature in #10656 and then "showing the way" in this PR @TowardOliver 🏆 ! We just merged #10706, so closing this PR now that the feature is implemented. |
Resolves #10656
Problem
Currently, including "unit_test" in the
DBT_EXCLUDE_RESOURCE_TYPES
env variable (or passing via--exclude-resource-type
) will prevent unit tests from running when using thedbt build
,list
andclone
commands ONLY.I want to extend this to also prevent unit tests from running when using the
dbt test
command.Solution
I've added a check to the TestSelector, to check the if unit_test has been set in the exclusion list. If it has, then it only allows data tests to run.
Default behaviour is to run both unit and data tests.
It's only a small / simple change. But it will get the job done of preventing unit tests from running on our Prod environments when running
dbt test
.Checklist