{"id":18762047,"url":"https://github.com/stanfordbdhg/xctruntimeassertions","last_synced_at":"2025-04-13T03:32:00.880Z","repository":{"id":151021445,"uuid":"611036830","full_name":"StanfordBDHG/XCTRuntimeAssertions","owner":"StanfordBDHG","description":"XCTest extensions to test runtime assertions and preconditions","archived":false,"fork":false,"pushed_at":"2025-03-16T22:27:38.000Z","size":59,"stargazers_count":2,"open_issues_count":2,"forks_count":1,"subscribers_count":13,"default_branch":"main","last_synced_at":"2025-04-12T12:00:06.740Z","etag":null,"topics":["assertion","fatalerror","precondition","runtime","stanford","swift","test","xcode","xctest"],"latest_commit_sha":null,"homepage":"https://swiftpackageindex.com/StanfordBDHG/XCTRuntimeAssertions/documentation/xctruntimeassertions","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/StanfordBDHG.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"custom":["Stanford Biodesign Digital Health Group.stanford.edu"]}},"created_at":"2023-03-08T01:11:00.000Z","updated_at":"2025-03-16T22:27:42.000Z","dependencies_parsed_at":"2024-08-15T17:58:22.056Z","dependency_job_id":"da6e2a45-7e0b-41f2-80e7-e6fd97026a7b","html_url":"https://github.com/StanfordBDHG/XCTRuntimeAssertions","commit_stats":null,"previous_names":["StanfordBDHG/XCTRuntimeAssertions","stanfordbdhg/xctruntimeassertions"],"tags_count":13,"template":false,"template_full_name":"StanfordBDHG/SwiftPackageTemplate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StanfordBDHG%2FXCTRuntimeAssertions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StanfordBDHG%2FXCTRuntimeAssertions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StanfordBDHG%2FXCTRuntimeAssertions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StanfordBDHG%2FXCTRuntimeAssertions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StanfordBDHG","download_url":"https://codeload.github.com/StanfordBDHG/XCTRuntimeAssertions/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248659677,"owners_count":21141158,"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":["assertion","fatalerror","precondition","runtime","stanford","swift","test","xcode","xctest"],"created_at":"2024-11-07T18:18:54.593Z","updated_at":"2025-04-13T03:32:00.871Z","avatar_url":"https://github.com/StanfordBDHG.png","language":"Swift","funding_links":["Stanford Biodesign Digital Health Group.stanford.edu"],"categories":[],"sub_categories":[],"readme":"\u003c!--\n\nThis source file is part of the Stanford RuntimeAssertions open-source project.\n\nSPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md)\n\nSPDX-License-Identifier: MIT\n  \n--\u003e\n\n# RuntimeAssertions\n\n[![Build and Test](https://github.com/StanfordBDHG/XCTRuntimeAssertions/actions/workflows/build-and-test.yml/badge.svg)](https://github.com/StanfordBDHG/XCTRuntimeAssertions/actions/workflows/build-and-test.yml)\n[![codecov](https://codecov.io/gh/StanfordBDHG/XCTRuntimeAssertions/branch/main/graph/badge.svg?token=PcUyqu5BOx)](https://codecov.io/gh/StanfordBDHG/XCTRuntimeAssertions)\n[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.7800545.svg)](https://doi.org/10.5281/zenodo.7800545)\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FStanfordBDHG%2FXCTRuntimeAssertions%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/StanfordBDHG/XCTRuntimeAssertions)\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FStanfordBDHG%2FXCTRuntimeAssertions%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/StanfordBDHG/XCTRuntimeAssertions)\n\nTest assertions and preconditions.\n\n\n## Overview\n\nThis library provides the necessary runtime support to support unit testing assertions and preconditions.\nThe library overloads Swifts runtime assertions:\n* `assert(_:_:file:line:)`\n* `assertionFailure(_:file:line:)`\n* `precondition(_:_:file:line:)`\n* `preconditionFailure(_:file:line:)`\n\nAlways call this method in your System under Test.\nOnly if requested within a unit test, their implementations are swapped to assert a runtime assertion.\nRelease builds will completely optimize out this runtime support library and direct calls to the original Swift implementation.\n\n### Configure your System under Test\n\nTo configure your System under Test, you just need to import the `RuntimeAssertion` library and call your runtime assertions functions as usual.\n\n```swift\nimport RuntimeAssertions\n\nfunc foo() {\n    precondition(someFooCondition, \"Foo condition is unmet.\")\n    // ...\n}\n```\n\n### Testing Runtime Assertions\n\nIn your unit tests you can use the `expectRuntimeAssertion(expectedCount:_:assertion:sourceLocation:_:)` and\n`expectRuntimePrecondition(timeout:_:precondition:sourceLocation:_:)` functions to test a block of code for which you expect\na runtime assertion to occur.\n\nBelow is a short code example demonstrating this for assertions:\n\n```swift\nimport RuntimeAssertionsTesting\nimport Testing\n\n@Test\nfunc testAssertion() {\n    expectRuntimeAssertion {\n        // code containing a call to assert() of the runtime support ...\n    }\n}\n```\n\nBelow is a short code example demonstrating this for preconditions:\n\n```swift\nimport RuntimeAssertionsTesting\nimport Testing\n\n@Test\nfunc testPrecondition() {\n    expectRuntimePrecondition {\n        // code containing a call to precondition() of the runtime support ...\n    }\n}\n```\n\n\u003e Tip: Both expectation methods also support the execution of `async` code.\n\n## Contributing\n\nContributions to this project are welcome. Please make sure to read the [contribution guidelines](https://github.com/StanfordBDHG/.github/blob/main/CONTRIBUTING.md) and the [contributor covenant code of conduct](https://github.com/StanfordBDHG/.github/blob/main/CODE_OF_CONDUCT.md) first.\n\n\n## License\n\nThis project is licensed under the MIT License. See [Licenses](https://github.com/StanfordBDHG/XCTRuntimeAssertions/tree/main/LICENSES) for more information.\n\n![Stanford Byers Center for Biodesign Logo](https://raw.githubusercontent.com/StanfordBDHG/.github/main/assets/biodesign-footer-light.png#gh-light-mode-only)\n![Stanford Byers Center for Biodesign Logo](https://raw.githubusercontent.com/StanfordBDHG/.github/main/assets/biodesign-footer-dark.png#gh-dark-mode-only)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstanfordbdhg%2Fxctruntimeassertions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstanfordbdhg%2Fxctruntimeassertions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstanfordbdhg%2Fxctruntimeassertions/lists"}