{"id":13868519,"url":"https://github.com/swiftlang/swift-testing","last_synced_at":"2025-12-11T23:02:39.185Z","repository":{"id":196163514,"uuid":"580189446","full_name":"swiftlang/swift-testing","owner":"swiftlang","description":"A modern, expressive testing package for Swift","archived":false,"fork":false,"pushed_at":"2025-05-07T22:37:57.000Z","size":4115,"stargazers_count":1964,"open_issues_count":80,"forks_count":104,"subscribers_count":126,"default_branch":"main","last_synced_at":"2025-05-07T23:28:25.604Z","etag":null,"topics":["software-quality","swift","swift-macros","testing","unit-testing"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/swiftlang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-12-19T23:51:30.000Z","updated_at":"2025-05-07T22:38:01.000Z","dependencies_parsed_at":null,"dependency_job_id":"be51eb06-b1be-45cb-94d0-959d5ee138f9","html_url":"https://github.com/swiftlang/swift-testing","commit_stats":null,"previous_names":["apple/swift-testing","swiftlang/swift-testing"],"tags_count":157,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swiftlang%2Fswift-testing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swiftlang%2Fswift-testing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swiftlang%2Fswift-testing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swiftlang%2Fswift-testing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/swiftlang","download_url":"https://codeload.github.com/swiftlang/swift-testing/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254082143,"owners_count":22011735,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["software-quality","swift","swift-macros","testing","unit-testing"],"created_at":"2024-08-05T19:00:58.874Z","updated_at":"2025-12-11T23:02:39.179Z","avatar_url":"https://github.com/swiftlang.png","language":"Swift","readme":"# Swift Testing\n\n\u003c!--\nThis source file is part of the Swift.org open source project\n\nCopyright (c) 2024 Apple Inc. and the Swift project authors\nLicensed under Apache License v2.0 with Runtime Library Exception\n\nSee https://swift.org/LICENSE.txt for license information\nSee https://swift.org/CONTRIBUTORS.txt for Swift project authors\n--\u003e\n\nSwift Testing is a package with expressive and intuitive APIs that make testing\nyour Swift code a breeze.\n\n[![CI status badge for main branch using main toolchain](https://github.com/swiftlang/swift-testing/actions/workflows/main_using_main.yml/badge.svg?branch=main\u0026event=push)](https://github.com/swiftlang/swift-testing/actions/workflows/main_using_main.yml)\n[![CI status badge for main branch using 6.2 toolchain](https://github.com/swiftlang/swift-testing/actions/workflows/main_using_release.yml/badge.svg?branch=main\u0026event=push)](https://github.com/swiftlang/swift-testing/actions/workflows/main_using_release.yml)\n\n## Feature overview\n\n### Clear, expressive API\n\nSwift Testing has a clear and expressive API built using macros, so you can\ndeclare complex behaviors with a small amount of code. The `#expect` API uses\nSwift expressions and operators, and captures the evaluated values so you can\nquickly understand what went wrong when a test fails.\n\n```swift\nimport Testing\n\n@Test func helloWorld() {\n  let greeting = \"Hello, world!\"\n  #expect(greeting == \"Hello\") // Expectation failed: (greeting → \"Hello, world!\") == \"Hello\"\n}\n```\n\n### Custom test behaviors\n\nYou can customize the behavior of tests or test suites using traits specified in\nyour code. Traits can describe the runtime conditions for a test, like which\ndevice a test should run on, or limit a test to certain operating system\nversions. Traits can also help you use continuous integration effectively by\nspecifying execution time limits for your tests.\n\n```swift\n@Test(.enabled(if: AppFeatures.isCommentingEnabled))\nfunc videoCommenting() async throws {\n    let video = try #require(await videoLibrary.video(named: \"A Beach\"))\n    #expect(video.comments.contains(\"So picturesque!\"))\n}\n```\n\n### Easy and flexible organization\n\nSwift Testing provides many ways to keep your tests organized. Structure\nrelated tests using a hierarchy of groups and subgroups. Apply tags to flexibly\nmanage, edit, and run tests with common characteristics across your test suite,\nlike tests that target a specific device or use a specific module. You can also\ngive tests a descriptive name so you know what they’re doing at a glance.\n\n```swift\n@Test(\"Check video metadata\",\n      .tags(.metadata))\nfunc videoMetadata() {\n    let video = Video(fileName: \"By the Lake.mov\")\n    let expectedMetadata = Metadata(duration: .seconds(90))\n    #expect(video.metadata == expectedMetadata)\n}\n```\n\n### Scalable coverage and execution\n\nParameterized tests help you run the same test over a sequence of values so you\ncan write less code. And all tests integrate seamlessly with Swift Concurrency\nand run in parallel by default.\n\n```swift\n@Test(\"Continents mentioned in videos\", arguments: [\n    \"A Beach\",\n    \"By the Lake\",\n    \"Camping in the Woods\"\n])\nfunc mentionedContinents(videoName: String) async throws {\n    let videoLibrary = try await VideoLibrary()\n    let video = try #require(await videoLibrary.video(named: videoName))\n    #expect(video.mentionedContinents.count \u003c= 3)\n}\n```\n\n### Cross-platform support\n\nSwift Testing is included in officially-supported Swift toolchains, including\nthose for Apple platforms, Linux, and Windows. To use the library, import the\n`Testing` module:\n\n```swift\nimport Testing\n```\n\nYou don't need to declare a package dependency to use Swift Testing. It's\ndeveloped as open source and discussed on the\n[Swift Forums](https://forums.swift.org/c/development/swift-testing/103)\nso the very best ideas, from anywhere, can help shape the future of testing in\nSwift.\n\nThe table below describes the current level of support that Swift Testing has\nfor various platforms:\n\n| **Platform**     | **Support Status** | **Qualification[^1]**  |\n| ---------------- | ------------------ | ---------------------- |\n| Apple platforms  | Supported          | Automated              |\n| Linux            | Supported          | Automated              |\n| Windows          | Supported          | Automated              |\n| Wasm             | Experimental       | Automated (Build Only) |\n| Android          | Experimental       | Automated (Build Only) |\n| FreeBSD, OpenBSD | Experimental       | Manual                 |\n\n[^1]:\n    Most platforms have \"Automated\" qualification, where continuous integration\n    automatically verifies that the project builds and passes all tests. This\n    ensures that any changes meet our highest quality standards, so it is our\n    goal for all supported platforms.\n\n    Presently, some platforms rely on manual test (\"Automated (Build Only)\"\n    qualification) or manual build and test (\"Manual\" qualification).\n\n### Works with XCTest\n\nIf you already have tests written using XCTest, you can run them side-by-side\nwith newer tests written using Swift Testing. This helps you migrate tests\nincrementally, at your own pace.\n\n## Documentation\n\nDetailed documentation for Swift Testing can be found on the\n[Swift Package Index](https://swiftpackageindex.com/swiftlang/swift-testing/main/documentation/testing).\nThere, you can delve into comprehensive guides, tutorials, and API references to\nmake the most out of this package. Swift Testing is included with the Swift 6\ntoolchain and Xcode 16. You do not need to add it as a package dependency to\nyour Swift package or Xcode project.\n\n\u003e [!IMPORTANT]\n\u003e Swift Testing depends on upcoming language and compiler features. If you are\n\u003e building Swift Testing from source, be aware that the main branch of this\n\u003e repository requires a recent **main-branch development snapshot** toolchain.\n\nOther documentation resources for this project can be found in the\n[README](https://github.com/swiftlang/swift-testing/blob/main/Documentation/README.md)\nof the `Documentation/` subdirectory.\n","funding_links":[],"categories":["Swift"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswiftlang%2Fswift-testing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswiftlang%2Fswift-testing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswiftlang%2Fswift-testing/lists"}