agentleFS
xu-xiangxu-xiang/everything-claude-code-zh/.cursor/rules/swift-testing.md

everything-claude-code-zh / rules

Cursor rule2k starsChanged 9 months agoMITView on GitHub

Swift 测试(Swift Testing)扩展了通用规则

Trending

More talk lately.thin dataabout the whole repository

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 0 mentionsMar 2026: 0 mentionsApr 2026: 0 mentionsMay 2026: 0 mentionsJun 2026: 0 mentionsJul 2026: 0 mentionsAug 2026: 0 mentionsSep 2026: 0 mentionsOct 2026: 1 mentionNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the xu-xiang/everything-claude-code-zh repository that our weekly crawl found: only 1 in all, so this is a hint, not a trend. There is no adoption data for this file yet.

Who's talking about xu-xiang/everything-claude-code-zh

The biggest 1 of 1 mention linking to the repository that our crawl found. Each line is their own headline.

The file

Files
swift-testing.md

Swift 测试 (Swift Testing)

本文件通过 Swift 特定的内容扩展了通用测试规则。

框架 (Framework)

对新测试使用 Swift Testing (import Testing)。使用 @Test 和 #expect:

@Test("User creation validates email")
func userCreationValidatesEmail() throws {
    #expect(throws: ValidationError.invalidEmail) {
        try User(email: "not-an-email")
    }
}

测试隔离 (Test Isolation)

每个测试都会获得一个新实例 —— 在 init 中进行设置(set up),在 deinit 中进行销毁(tear down)。测试之间不得共享可变状态(mutable state)。

参数化测试 (Parameterized Tests)

@Test("Validates formats", arguments: ["json", "xml", "csv"])
func validatesFormat(format: String) throws {
    let parser = try Parser(format: format)
    #expect(parser.isValid)
}

覆盖率 (Coverage)

swift test --enable-code-coverage

参考 (Reference)

有关基于协议的依赖注入(protocol-based dependency injection)和 Swift Testing 的模拟模式(mock patterns),请参阅技能(skill):swift-protocol-di-testing。

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.