You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/concepts/tests.md
+17Lines changed: 17 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -463,6 +463,23 @@ You can also run tests that match a pattern or substring using a glob pathname e
463
463
$ sqlmesh test tests/test_*
464
464
```
465
465
466
+
You can pass `--local` to run tests without loading state from the configured state connection:
467
+
468
+
```bash
469
+
$ sqlmesh test --local
470
+
```
471
+
472
+
This keeps offline runs and commit hooks from opening a connection to the state backend.
473
+
474
+
In multi-repository setups, or when running tests for only a subset of projects, models that exist only in remote state are not loaded under `--local`. Unlike [`sqlmesh lint --local`](../guides/linter.md), which reports additional errors in that situation, a test whose model is missing is **skipped with a warning and the run still succeeds**:
475
+
476
+
```
477
+
[WARNING] Model '"memory"."bronze"."a"' was not found at tests/test_a.yaml
478
+
.**Successfully Ran `1` Tests Against `duckdb`**
479
+
```
480
+
481
+
So a passing exit code alone does not mean every test you expected actually ran. Watch the output for these warnings, and keep in mind that a hook using `--local` will not fail on them.
482
+
466
483
### Testing using notebooks
467
484
468
485
You can execute tests on demand using the `%run_test` notebook magic as follows:
# The parent callback constructs Context before Click invokes the subcommand, so inspect its
135
+
# parsed args here.
136
+
if (
137
+
ctx.invoked_subcommandinOPTIONAL_LOCAL_COMMANDS
138
+
and"--local"inctx.meta["subcommand_args"]
139
+
):
134
140
load_state=False
135
141
136
142
iflen(paths) ==1:
@@ -811,6 +817,12 @@ def create_test(
811
817
multiple=True,
812
818
help="Select specific models to run unit tests for.",
813
819
)
820
+
@click.option(
821
+
"--local",
822
+
is_flag=True,
823
+
expose_value=False,
824
+
help="Run tests using only locally loaded project files without loading state. Tests whose model is not loaded are skipped with a warning rather than failing.",
0 commit comments