TEST @tag
Test files only
This annotation applies only to test files run by the SQL test runner (npgsqlrest --test). It is distinct from the endpoint TAGS annotation, which scopes routine annotations by volatility.
Declare tags on a test file, so runs can be narrowed with TestRunner.Tag / ExcludeTag.
Syntax
Placed in the file's header — the leading -- line comments before the first SQL statement or HTTP block:
sql
sql
-- @tag name [name ...]- Names may be whitespace- or comma-separated:
-- @tag smoke authand-- @tag smoke, authare equivalent. - The annotation is repeatable; tags accumulate. Matching is case-insensitive.
Example
sql
sql
-- @tag auth, smoke
-- Test: GET /api/get-users requires authentication.
/*
GET /api/get-users
*/
select status = 401, 'anonymous request is rejected' from _response;Selective runs:
sh
sh
# only the smoke suite
npgsqlrest ./config.json --test --testrunner:tag=smoke
# everything except slow tests
npgsqlrest ./config.json --test --testrunner:excludetag=slow
# smoke AND auth files, but never slow ones (exclude wins)
npgsqlrest ./config.json --test --testrunner:tag=smoke,auth --testrunner:excludetag=slowTags via a shared profile
Tags declared in an included annotation profile count as if written in the file — a shared \ir include can tag a whole family of tests at once:
sql
sql
-- tests/shared/isolated_database.sql (an annotation profile: comments only)
-- @setup CreateIsolatedDb
-- @teardown DropIsolatedDb
-- @connection Isolated
-- @tag isolation, slowsql
sql
-- a test file attaching the profile
\ir shared/isolated_database.sql
select 1 = 1, 'runs isolated, tagged isolation+slow via the profile';Related
- Test Runner configuration —
Tag,ExcludeTag,Filter - TEST @setup — header annotations share the same placement rules
- Testing Guide