testing
Skill0 starsChanged 4 months agoApache-2.0View on GitHub
Design, structure, and place Swift Institute tests and benchmarks — suite shape, nested test packages, snapshot tests, Swift Testing framework traps, and executable benchmark mechanics. Apply whenever writing, restructuring, or reviewing tests or performance measurement.
123 other projects use a version of this.
Adopted by
Most recently taken up by
- timmo001/skillstheir own version, first seen Oct 5, 2026
- kortix-ai/sunatheir own version, first seen Oct 5, 2026
- gilsmt/skillstheir own version, first seen Oct 4, 2026
- andeeplus/aplustheir own version, first seen Oct 4, 2026
- JetBrains/intellij-communitytheir own version, first seen Oct 3, 2026
- shinpr/codex-workflowstheir own version, first seen Oct 2, 2026
Used with
Projects with it also use oss-pr, pr-automation and 9 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
CES-LtdSkilloss-pr
Use when creating a pull request, after committing changes, or when user invokes /oss-pr. Covers branch management, quality checks, commit, push, and PR creation.
Also in 3 projects that use this
CES-LtdSkillpr-automation
PR Automation Orchestrator: poll open PRs, check CI, run review, fix, and merge eligible PRs. Use when: (1) Invoked by daemon via scripts/pr-automation.sh, (2) User says "/pr-automation".
Also in 3 projects that use this
ffsshhttiikkSkillcicd
Continuous integration and delivery pipelines
Also in 4 projects that use this
ffsshhttiikkSkillnetworking
Practical application and coding skills for Networking
Also in 3 projects that use this
Cogni-AI-OUSkilldotfiles
Reference for repository dotfiles, including their purposes, standard configurations, and usage guidelines. You MUST load this skill when configuring, troubleshooting, or understanding repository dotfiles.
Also in 3 projects that use this
pluginagentmarketplaceSkillmicroservices
Microservices architecture patterns and best practices. Service decomposition, inter-service communication, and distributed data management.
Also in 3 projects that use this
- +2 more from CES-Ltd
- +1 more from ffsshhttiikk
Other versions123 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 123
- lobehub/lobehub★ 83ksame name
- iOfficeAI/AionUi★ 33ksame name
- JetBrains/intellij-community★ 21ksame name
- kortix-ai/suna★ 20ksame name
- modelcontextprotocol/inspector★ 11ksame name
- microsoft/fast★ 9.7ksame name
- bytebase/dbhub★ 3.6ksame name
- theopenco/llmgateway★ 1.7ksame name
- BankrBot/skills★ 1.2ksame name
- microsoft/CCF★ 875same name
113 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository9 other files it gives its agents.
- architectureSkill
- ci-cdSkill
- compositionSkill
- decompositionSkill
- documentationSkill
- githubSkill
- instituteSkill
- reviewSkill
- swiftSkill
The file
We split this skill into the rules it gives an agent
5 rules. 0 are common, 2 are distinctive, and 3 are very specific to this project.
0
Common
Most of the 105 edited versions we read keep these.
2
Distinctive
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 48
Search for both, and do not "fix" one spelling into the other: the macro emits its own.
- Very specific: line 73
Verify any proposed deviation with a swiftc -typecheck probe before committing to it.
- Very specific: line 91
Prefer the generic macro-test support with a Swift Testing failureHandler routing to Issue.record.
- Distinctive: line 96
Do not add copyability to a production API to satisfy a test macro.
- Very specific: line 108
Test directories are flat siblings under Tests/.
“Common” is measured: kept by at least 6 in 10 of the 105 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Swift testing
Name the invariant, the input space, the observable result, and the failure signal before choosing a fixture. Test through the narrowest interface that expresses the behavior, on the boundary the behavior actually depends on — a same-target test cannot prove a cross-module claim, however green it is. Prefer laws and reference models over repeated examples.
Suite structure
Tests are a subdomain of the source domain, not a parallel vocabulary. Each top-level suite is declared as an extension of the source type it covers:
extension <SourceType> {
@Suite struct <TestSubdomain> {
@Suite struct Unit {}
@Suite struct `Edge Case` {}
@Suite struct Integration {}
}
}
extension <SourceType>.<TestSubdomain>.Unit {
@Test func `descriptive scenario name`() { }
}Reference source types directly. No local convenience typealiases, no compound FooTests
top-level structs. Test fixtures — phantom-tag enums, sample values — live as nested members of
the test subdomain. Test names state the condition and the expected behavior in readable words;
do not repeat the suite or type name to imitate an XCTest method.
The sub-suite names, and the split in them
Unit, `Edge Case`, and Integration are the hand-written set, and the reason to hold
to a fixed set is that it makes a cross-package search possible at all. Adding a fourth
category of your own defeats that for everyone.
That reason is currently half-defeated, and it is worth knowing before you search. The
Institute's own #Tests macro generates five suites — Unit, EdgeCase, Integration,
Performance, Snapshot — so the corpus carries two spellings of the edge-case suite and two
categories this section does not describe. A search for `Edge Case` misses every
macro-generated suite, and a search for EdgeCase misses the larger hand-written population.
Search for both, and do not "fix" one spelling into the other: the macro emits its own.
Host types that break the extension pattern
Where the extension shape cannot compile or cannot be discovered, use a top-level single-word
backticked suite (@Suite struct \Index Tests``) with the same sub-suites.
- Generic type, unspecialized (
extension Index { @Suite struct Test {} }) — hard error,@section cannot be used in a generic context. Test bodies there are also generic, so a localstruct Tag {}inside a test body will not compile either. - Generic type at a concrete specialization (
extension Index<Int> { @Suite struct Test {} }) — compiles and is SILENTLY never discovered. Nothing fails; the tests just do not run. - Nested-in-generic types inherit the outer generic parameters and fail the same way.
- Protocol extension —
static stored properties not supported in protocol extensions; the suite macro synthesizes static storage a protocol extension cannot host. - A host type named
Protocol(e.g.RFC_791.Protocol) — the@Testmacro emits expression-position references where Swift's.Protocolmetatype grammar hijacks the name even backticked. - Packages that declare no type of their own, only constrained extensions.
Scope "this type already carries a Test suite" collision checks per test target: a same-named
suite in a sibling test target is not a collision, because extending a type nested in another
module's test target is illegal Swift anyway. When a backticked top-level name is already
claimed, append the new suite's distinguishing tokens rather than nesting deeper.
Verify any proposed deviation with a swiftc -typecheck probe before committing to it. The
list above is what has been hit, not what can be hit.
Framework traps
#expectcopies its operands. Project a~Copyablevalue to a Copyable observation first;#expect(value.property)also synthesizes a receiver-copying property access, so bind the property to a local first.== nilon a~CopyableOptional does not work in#expect— binary comparison requires Copyable operands. Useif let/guardpattern matching.- Two
awaits inside one#expectfails type inference. Extract each side to aletbinding, then compare. @Testgenerates@section-attributed globals whose mangled names scale with nesting depth times test count; deep enough, the aggregate exceeds compiler thresholds and surfaces as a cryptic@sectionerror. Drop to one suite per file and shorten the nesting suffix.- Macro expansion tests validate the expansion, not whether the macro may be attached at a given site. Neither harness checks form-vs-site applicability, so macro coverage must include at least one real consumer site compiled through the coordinator.
- Prefer the generic macro-test support with a Swift Testing
failureHandlerrouting toIssue.record; do not pull XCTest or Foundation in for fixture convenience. - A mock produced by
unsafeBitCastover a pointer-likeBitwiseCopyabletype must offset its tag away from zero. The all-zeros pattern is whatOptional<T>reads as.none, so a zero-tagged mock is indistinguishable from "no value". - Do not add copyability to a production API to satisfy a test macro.
Main-actor isolation checks. pthread_main_np() is Darwin-only, and on Linux the MainActor
executor does not necessarily run on the thread glibc considers the process's initial thread —
so a @MainActor body can report a non-main OS thread while genuinely running isolated. Do not
use it as a MainActor proxy. Capture the thread identity at the top of the @MainActor test
body and compare against it: the MainActor executor is a single fixed thread on both platforms,
so the captured identity is stable across suspension points, and no Foundation dependency is
needed either way.
Test layout and dependencies
Test directories are flat siblings under Tests/. Test support is a .library product, never
a .testTarget — a test target cannot be consumed across packages. Product and target names
use spaces ("Memory Primitives Test Support"); imports use underscores (import
Memory_Primitives_Test_Support); the path is Tests/Support. Test support may depend on
production products; production products never depend on test support. Search for an existing
support product before adding helpers — reusable helpers live with the lowest layer that can
own them, package-specific fixtures stay local.
A package needing test-only third-party dependencies — macro-testing, snapshot support, a driver for an integration test — puts them in a nested test manifest rather than the main one, so a consumer resolving the package never pulls a test harness:
swift-<package>/
Package.swift # unit test targets, explicit path:
Sources/<Module>/
Tests/
Package.swift # depends on ".." — the parent package
<Module> Tests/
<Module> Snapshot Tests/
.snapshots/ # committedMost packages need no such manifest, and most do not have one: a .testTarget in the main
manifest links the toolchain's testing framework without declaring anything. Reach for the
nested manifest when a third-party test dependency appears, not before. The corpus is not
uniform here — some main manifests do carry macro- and snapshot-testing dependencies, so a
package you copy from may not be an example of this.
SwiftPM skips automatic target discovery in any directory containing its own Package.swift,
so both manifests need explicit path:. The parent uses path: "Tests/<Module> Tests"; the
nested manifest's root is Tests/, so its targets use path: "<Module> Snapshot Tests" —
without it SwiftPM looks in Tests/Tests/. The nested package is named testing, reaches its
parent as .package(path: ".."), mirrors the parent's upcoming-feature settings, and gitignores
the nested .build/, .swiftpm/, and .benchmarks/. Everything else it depends on is declared
by URL like any other dependency. A relative path to a sibling package resolves only on a
machine whose checkout happens to match, which is why the parent is the only one spelled that
way.
Snapshot references live in .snapshots/ beside the test source and are committed.
Recording modes: .missing records new and compares existing (the default), .all always
records, .failed records on failure and still fails, .never compares only and fails when
missing — use .never in CI, where recording a snapshot means asserting nothing.
Verification
Filter while iterating, then run the affected package fresh when reporting:
institute package test --argument=--filter --argument "Behavior"
institute package test --freshA filtered run proves only that filter. For what a run has to satisfy before it counts as
evidence — including why a gate covering canImport-conditional suites has to start from a
clean worktree — see the institute skill.
TSan legs on packages whose dependency closure carries ~Copyable & ~Escapable
lifetime-dependent accessor projections use the carved invocation:
institute package test --argument=--sanitize=thread \
--argument=--scratch-path --argument=.build-tsan \
--argument=-Xswiftc --argument=-Xllvm \
--argument=-Xswiftc --argument=-sil-disable-pass=lifetime-dependence-diagnostics.build-tsan is used for every sanitized invocation and never without --sanitize=thread;
sanitized and unsanitized artifacts never share a scratch. A seeded race positive control rides
every TSan gate with its expected nonzero report count asserted — TSan reports do not fail
swift-testing runs, so pass criteria count WARNING: ThreadSanitizer lines, never test counts.
Elsewhere
- Benchmark shape, mechanics, and when an isolated measurement is not evidence — benchmarks.md.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

