Skip to content

feat(test): select unit tests by name and require unique test names - #989

Merged
kvlonge merged 2 commits into
mainfrom
feat/unit-test-selection
Oct 6, 2026
Merged

kvlonge merged 2 commits into
mainfrom
feat/unit-test-selection

Conversation

@kvlonge

@kvlonge kvlonge commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Why

Unit tests could only be selected through the models they read, so running one test meant building and testing its whole model scope. Test and scenario names could also collide with models and other resources, which makes a name-based selector ambiguous.

Changes

  • Globally unique names: unit-test and scenario names now join the project-wide unique-name rule (D007) alongside models, seeds, sources, functions, providers and hooks. Duplicate test names are still reported by the existing S018 check. Fixtures that reused a model's name were renamed, including the dbt-interop scenario.
  • Select unit tests by name: sqb test and sqb build accept test:<name>, or a bare name that matches no other resource, with glob patterns. Test selectors union with resource selectors and --case still narrows. Selecting only tests runs them without building models, and the defer-clone prephase is skipped.
  • Errors:
    • Every other command, including the Dagster DAG selection, rejects unit-test selectors with S013.
    • + or , on a unit-test selector also raises S013.
    • Unknown names raise S007 with "did you mean" suggestions.
    • A malformed part such as a trailing comma still reports its own parse error (S001).
  • Empty or blank --select values keep their old meaning and select nothing.
  • Docs and the generated skill cover selection and uniqueness.

Verification

  • make test (11031 passed).
  • E2E: the sqb test and scenario directories, selector surface, unused-CTE rules and Dagster selection parity. New E2E cases cover selection by name, duplicate names and empty --select values; the empty-value cases fail on the previous head.
  • Unit tests for the selector split, the trailing-comma S001 and the Dagster S013. Discovery passes on every checked-in project, playground template and test generator.
  • Compile performance guards pass; fingerprints are unchanged.
  • ruff, ty, fensu check, make check-ci and the hygiene scan.

Unit-test names (TEST name or file stem) and scenario names now join the
global resource-name rule with models, sources, seeds, functions, Python
nodes, providers and hooks. A clash is a compile error naming both kinds and
files; cases of one parameterized test share its name. Fixtures that named a
test or scenario after its model are renamed.
sqb test and sqb build accept a unit-test name, bare or as test:<name>, with
glob patterns. Test selectors union with resource selectors, --case still
narrows, and selecting only tests runs them without building models. Every
other command rejects unit-test selectors with S013, and unknown names
suggest the closest selectable names.
@kvlonge
kvlonge enabled auto-merge (squash) October 6, 2026 20:24
@kvlonge
kvlonge merged commit 896c452 into main Oct 6, 2026
32 checks passed
@kvlonge
kvlonge deleted the feat/unit-test-selection branch October 6, 2026 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant