# Instructions for Fluent TestSuite API

Always reference the `atf` instructions (`get_fluent_knowledge` kind `instruct`) and the TestSuite API specification for details.

1. Import `TestSuite` from `@servicenow/sdk/core`. Unlike the `atf.*` step families, this is a **top-level constructor**, not a step reached through the `Test()` callback — it groups whole tests rather than authoring behavior inside one. Author the tests themselves with `Test()` per the shared scaffold in the `atf` instructions (`get_fluent_knowledge` kind `instruct`), then reference them here.
2. One `TestSuite()` call writes the suite row (`sys_atf_test_suite`) plus one membership row (`sys_atf_test_suite_test`) per `tests` entry. Do not author `sys_atf_test_suite_test` with `Record()` — membership is derived, and hand-written rows will fight the generated ones.
3. `$id` and `name` are the only mandatory properties. A suite with neither `tests` nor `testFilter` is valid and useful — that is exactly how you create a container for other suites to nest under via `parent`.
4. **Run order comes from array position in `tests`, not from a field.** Reorder the array to reorder the run. Only reach for the object form's `order` to preserve *existing* custom or gapped values (100, 200, 300...) when adopting Fluent for a suite that already has them on the instance; pinning order on a greenfield suite just creates a second source of truth. Pinned and derived entries may mix, but a collision between two entries' final order emits a build-time hint because ATF does not guarantee run order between ties.
5. Use the bare-reference form — a `Test(...)` return value, or a raw 32-char sys_id — by default. Switch to the object form only when you need `abortOnFailure` or `order`. Prefer a `Test(...)` variable over a raw sys_id so the reference is checked at build time and survives a re-deploy. Only **standard** tests are suite members (SDK v4.14.0+ types an entry as `TestInstance | string`): a reusable test (`isReusable: true`) is a compile error (TS2322), because it runs only as a step inside another test via `atf.executeTest`. List the standard tests that call it.
6. **`abortOnFailure` is not universally honored.** It stops the rest of the suite under the standard runner, but ATF's cloud/parallel test runner ignores it and always runs every test. Never rely on it as a correctness guarantee — treat it as an optimization for the sequential runner, and make each test independently valid.
7. Declaring the same test twice is a **hard build error**, compared by *resolved sys_id* — so a `Test(...)` variable and that same test's raw sys_id in the same array collide even though they look different. Deduplicate before building.
8. **Do not combine `testFilter` with an explicit `tests` list.** The platform allows it, and Fluent only emits a hint, but the two mechanisms conflict: ATF re-syncs membership from `testFilter` whenever the suite is saved on the instance, so a manually-listed test that does not match the filter can be silently removed. Pick one mechanism per suite.
9. Remember `testFilter` is evaluated **on the platform, at save time — not during a Fluent build**. A freshly built and installed suite will show no membership rows from it until the instance saves the suite, so do not treat an empty membership list right after deploy as a build failure.
10. For nesting, `parent` must reference an already-declared `TestSuite(...)` (normal declare-before-use), which structurally prevents a cycle. A raw sys_id equal to the suite's own `$id` is rejected at build time, but a **longer cycle built from raw sys_id strings across several suites is not statically detected** — the platform catches it on save. Prefer variable references over sys_ids for exactly this reason.
11. **`TestSuite()` is authoring only.** It never triggers, schedules, or runs anything. Do not expect a build or deploy to execute the suite. Run it through ATF's UI, ATF's scheduler, or CI/CD — the `now-sdk cicd` command (surfaced by this MCP server as the cicd_fluent_test tool) runs a suite by sys_id or name, then watches or fetches its result.
12. Group by a reason a reader can name: one feature area, or a smoke set that gates a build. A suite that merely collects every test in the app duplicates ATF's existing all-tests view and earns nothing.
13. Skip redundant defaults (`active: true`, `abortOnFailure: false`) — they round-trip back as omitted. `TestSuite` accepts `protectionPolicy` and `$override`, but **not** `$meta` (no `installMethod`, no `useEsLatest`).
