AGENT SKILL

test-harness

Write or run tests against the NSail harnesses — which layer owes the proof (Architecture, Stack, kit WebApi.Tests on Postgres, bUnit, Apps, browser E2E), HandlerHost, the Release-build E2E host, Api.Send, culture and viewport. Use for a kit, bUnit or E2E test, deciding whether a fix earns a regression test, a flaky or instantly-failing suite, or reporting test totals.

License 许可
MIT
最近更新
2026-11-14
Stars
★ 4
Forks
0

01 前言 Front Matter

name
test-harness
description
Write or run tests against the NSail harnesses — which layer owes the proof (Architecture, Stack, kit WebApi.Tests on Postgres, bUnit, Apps, browser E2E), HandlerHost, the Release-build E2E host, Api.Send, culture and viewport. Use for a kit, bUnit or E2E test, deciding whether a fix earns a regression test, a flaky or instantly-failing suite, or reporting test totals.

03 SKILL.md 正文

Test harness

The layer map and rulings are doctrine: read ${CLAUDE_PLUGIN_ROOT}/doctrine/testing.md first — each layer proves one kind of truth, and a test in the wrong layer proves nothing twice. This skill surfaces the lore that has been paid for. When they disagree, the doctrine wins.

Which layer owes the proof

Layer Proves
test/Architecture (products' repository) form — a doctrine rule quantified over the whole tree
test/Stack/... a Stack module's own behavior, offline
test/Kits/.../WebApi.Tests handler doctrine against real Postgres (NSail.Data.Testing)
test/Kits/.../Shared.Tests, test/Stack/Components screen behavior through real DOM events (bUnit)
test/Apps/... composition seams — what a screen actually sends
test/Apps/.../E2E only what a real browser sees; a THIN layer on purpose

The kits are covered; the Apps layer is where defects pool. When an app story touches a seam, the seam's test rides the story.

Kit harness recipe

  • HandlerHost.Start(prefix, contextFactory, compose) — ephemeral database per collection on the real local Postgres; the design-time factory migrates it with the composing app's chain. Never hand-type a setup list — it rots the day a kit joins one app only.
  • Every unique value embeds a fresh Guid: the collection shares one database, so a reused literal collides with a unique index. Except a phone number: a Guid cannot spell one the numbering plan admits, so it is drawn with Handsets.Draw() (test/Shared/Directory/Handsets.cs) — why in testing.md, "Every harness".
  • The composition registers a flat wide policy (any authenticated session), so the handler is what answers — gate semantics belong to NSail.Security.Tests. The exception is a gate-proof collection (the PolicyGate precedent): it registers NO policies, so a denial can only come from the stored constraint under test.

Browser e2e recipe

  • The suite builds the Release host it spawns, every run. OpticalHostProcess runs the Release build (the #if DEBUG sign-in shortcuts are compiled out — the only way the sign-in path is the real one), and no slot produces that output: dotnet build/dotnet test are Debug. Rebuilding only when the file is missing leaves a stale Release host exercising last week's app.
  • Arrange over HTTP, act through the UI. Api.Send posts a message to its own [Http] route over the signed-in context's cookie jar — reference rows cost one request, and what the path proves is the screen it is named after.
  • Declare the language and the viewport: OpticalE2EFixture.NewContext writes the culture cookie and a desktop viewport wide enough that the container-query columns are present — an install-default language change breaks tests that assume one.
  • bUnit drives REAL DOM events; value-writing without events is the documented automation trap and proves nothing about bindings.

Flaky suites

  • A whole assembly failing instantly on connects is the shared Postgres under cross-slot load — rerun serial before suspecting code. RetryingLazy keeps a faulted sweep from poisoning an assembly.

When a fix earns a test (testing.md, ruling 7 bounding ruling 6)

A test per contract, never a test per anecdote. A fix earns a test when the defect exposed a promise nobody was watching. The question at every close is what promise was unwatched? — if the answer names a promise, the pin lands (red first, the fix turns it green); if the answer is "we were careless here once", the fix ships alone and the story says so. A bug that reached a USER proves a flow nobody pinned, and a flow is a promise — its scenario lands in the catalog (NSail.Optical.Scenarios.Tests against src/Apps/Optical/docs/test-scenarios.md) before the fix. The same shape landing three times in a week is a class that earns a net, not three regression tests.

Repeatable verification lands as a test; prose is for what only the eye judges. Form rules quantified over the tree go to Architecture.Tests (products' repository; the Stack's own in test/Stack) with an explicit exemption list, never a recurring manual audit.

Reporting

The suite total is the tree's, verified against find test -name '*.Tests.csproj' | wc -l, never a number carried from memory. No coverage target, deliberately.

04 同仓库更多 Skills

nsail-ar
nsail-ar/nsail-stack

new-message

Add an NSail operation end to end — a message in the Sdk ([Http] route, validation), its IHandler in WebApi, the Row/Ref/Model projection, BusinessException failures and strings; endpoint, DI and client are generated. Use for a query or command such as ListInvoices or CreatePayment, when choosing a verb (there is no Save), or on SenderNotFound.

★ 4
nsail-ar
nsail-ar/nsail-stack

new-mapping

Write or convert a handler so the generated entity mapper copies the data — [MapFrom] a message onto an entity graph, [MapTo] a Row/Model/Ref projection, EntityMapper.Map/Upsert/Project. Use when a handler would assign entity.X = message.X by hand, build a new Entity from a message, merge a child collection by key, or project with .Select; when adding a Create/Update/List/Get/Lookup to a kit; or when a build says NSG004 to NSG013 or NSG025.

★ 4
nsail-ar
nsail-ar/nsail-stack

new-icon

Add an icon to an NSail icon catalog (NsIcons, a kit's or app's like ProductsIcons or OpticalIcons, a Stack library's own) from a Material Symbols path. Use when a screen, menu entry, button or field needs a glyph no catalog has, instead of Icons.Material.*, or when a pasted icon renders as nothing or a dot. Covers the 960-grid viewBox transform, catalog choice and sizing.

★ 4
nsail-ar
nsail-ar/nsail-stack

doctrine

The Stack's architecture — which page to read before touching a message, handler, entity, migration, tenancy, permission, screen, Ns* component, test, React client, localization key or project layout. Use before editing code that builds on the Stack, when a CLAUDE.md routes the Stack's doctrine, or when asked how the Stack wants something done.

★ 4
nsail-ar
nsail-ar/nsail-stack

convert-to-nsload

Convert a screen's data read into an NsLoad region (OnLoad, Reload, Retry, NsPartial.Handoff for dashboard cards). Use whenever you touch a Blazor screen or card that loads in OnCreatedAsync, OnParametersSetAsync or OnInitializedAsync, or when a load failure shows as a toast, a card reads twice, or an empty state lies about a failed read.

★ 4