sqlmesh icon indicating copy to clipboard operation
sqlmesh copied to clipboard

Smarter Unit Test Execution

Open cmgoffena13 opened this issue 3 months ago • 2 comments

Right now all unit tests run during a plan unless the --skip-tests flag is used.

We already have the plan which shows us which models are affected by the changes. It makes sense to trim the unit tests that run during a plan to only the models that are affected by applying the plan.

I am not sure what behavior should happen for the --skip-backfill / --dry-run flags, but my initial thought is to skip all tests for this flag as well since it's considered a no-op operation.

To have backwards compatibility, we can add in an --all-tests flag to the plan command. I can see this being useful for CI dry-runs as well as edge cases that may show up.

cmgoffena13 avatar Aug 21 '26 03:08 cmgoffena13

After thinking about it: the --skip-backfill / --dry-run flags already run all tests, so to make behavior more predictable, it makes more sense to just limit tests to model changes in a dry-run too. Keeping the --all-tests flag for backwards compatibility though.

cmgoffena13 avatar Aug 21 '26 05:08 cmgoffena13

After discussion, have decided to flip the logic and have the smarter unit test execution be opt in with a flag called --test-changed-only

cmgoffena13 avatar Aug 29 '26 04:08 cmgoffena13