testing
作者: contentstack
XCTest—布局、模拟、测试夹具、SwiftLint/Slather、离线测试、Linux清单。
npx skills add https://github.com/contentstack/contentstack-utils-swift --skill testingTesting – Contentstack Utils Swift
When to use
- Adding or changing tests under
Tests/ContentstackUtilsTests/. - Debugging flaky tests; improving fixtures or mocks.
Runner and tooling
- XCTest via
swift test(SPM) and/or Xcode schemeContentstackUtils-Package(ContentstackUtils.xcodeproj), matching.github/workflows/ci.yml. - SwiftLint:
.swiftlint.yml;Tests/ContentstackUtilsTests/Constants.swiftis excluded—other test files are linted. - Slather:
.slather.ymlignoresTests/*in coverage reports; still add tests for new production code inSources/ContentstackUtils/when practical.
Test naming and layout
- Target:
ContentstackUtilsTests; pathTests/ContentstackUtilsTests/. - File names:
*Tests.swift,*Test.swift, or feature-oriented names (GQLJsonToHtml.swift,JsonNodes.swift,VariantUtilityTests.swift). - Fixtures and mocks: Prefer
JsonNodes.swift,JsonNodesHtmlResults.swift,EmbededModelMock.swift,CustomRenderOptionMock.swift,TestClient.swift, etc., before adding parallel helpers.
Integration vs unit
- No separate integration tree: tests live in
ContentstackUtilsTestswith mocks for API-shaped payloads—no live network or credentials in CI.
Linux / discovery
- Maintain
XCTestManifests.swiftif your workflow requires explicit Linux test discovery.
Secrets
- Tests are offline; do not commit API keys or real tokens.
References
skills/dev-workflow/SKILL.mdskills/code-review/SKILL.md