{"id":13489633,"url":"https://github.com/mrackwitz/CatchingFire","last_synced_at":"2025-03-28T05:31:08.091Z","repository":{"id":56905705,"uuid":"38847504","full_name":"mrackwitz/CatchingFire","owner":"mrackwitz","description":"Test Library for Swift's Error Handling","archived":false,"fork":false,"pushed_at":"2016-04-04T13:03:03.000Z","size":143,"stargazers_count":75,"open_issues_count":2,"forks_count":7,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-16T07:45:56.064Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/mrackwitz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-07-09T21:59:49.000Z","updated_at":"2022-05-16T09:32:15.000Z","dependencies_parsed_at":"2022-08-21T01:50:50.299Z","dependency_job_id":null,"html_url":"https://github.com/mrackwitz/CatchingFire","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrackwitz%2FCatchingFire","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrackwitz%2FCatchingFire/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrackwitz%2FCatchingFire/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrackwitz%2FCatchingFire/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrackwitz","download_url":"https://codeload.github.com/mrackwitz/CatchingFire/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245978200,"owners_count":20703675,"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":[],"created_at":"2024-07-31T19:00:32.199Z","updated_at":"2025-03-28T05:31:06.887Z","avatar_url":"https://github.com/mrackwitz.png","language":"Swift","readme":"# CatchingFire\n\n[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](https://github.com/mrackwitz/CatchingFire/blob/master/LICENSE)\n[![CocoaPods](https://img.shields.io/cocoapods/v/CatchingFire.svg?style=flat)](https://github.com/mrackwitz/CatchingFire)\n\nCatchingFire is a Swift test framework, which helps making expectations against the error handling of your code. It provides for this purpose two higher-order functions, which take throwing functions and check whether the given closure throws or not. It integrates seamlessly with the expecters provided by `XCTest`.\n\n## Usage\n\n### AssertNoThrow\n\n`AssertNoThrow` allows you to write safe tests for the happy path of failable functions.\nIt helps you to avoid the `try!` operator in tests.\n\nIf you want to test a function, which may fail in general, you may think of using `try`.\nBut this would mean that you have to declare your test method as throwing, which causes that\nXCTest doesn't execute the test anymore.\n\nSo in consequence, you would usually need to write:\n\n```swift\nXCTAssertEqual(try! fib(x), 21)\n```\n\nIf the expression fails, your whole test suite doesn't execute further and aborts immediately,\nwhich is very undesirable, especially on CI, but also for your workflow when you use TDD.\n\nInstead you can write now:\n\n```swift\nAssertNoThrow {\n    XCTAssertEqual(try fib(x), 21)\n}\n```\n\nOr alternatively:\n\n```swift\nAssertNoThrow(try fib(x)).map { (y: Int) in\n    XCTAssertEqual(y, 21)\n}\n```\n\nIf the expression fails, your test fails.\n\n### AssertThrow\n\n`AssertThrow` allows to easily write exhaustive tests for the exception paths of failable functions.\nIt helps you to avoid writing the same boilerplate code over and over again for tests.\n\nIf you want to test a function, that it fails for given arguments, you would usually need\nto write:\n\n```swift\ndo {\n    try fib(-1)\n    XCTFail(\"Expected to fail, but did not failed!\")\n} catch Error.ArgumentMayNotBeNegative {\n    // succeed silently\n} catch error {\n    XCTFail(\"Failed with a different error than expected!\")\n}\n```\n\nInstead you can write now:\n\n```swift\nAssertThrow(Error.ArgumentMayNotBeNegative) {\n    try fib(-1)\n}\n```\n\nIf the expression or closure doesn't throw the expected error, your test fails.\n\n\n## Installation\n\nCatchingFire is available through [CocoaPods](http://cocoapods.org). To install\nit, simply add it to your test target in your Podfile:\n\n```ruby\nuse_frameworks!\ntarget \"AppTest\" do\n  pod 'CatchingFire'\nend\n```\n\n\n## Author\n\nMarius Rackwitz, git@mariusrackwitz.de  \nFind me on Twitter as [@mrackwitz](https://twitter.com/mrackwitz).\n\n\n## License\n\nVersion is available under the MIT license. See the LICENSE file for more info.\n","funding_links":[],"categories":["Libs"],"sub_categories":["Testing"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrackwitz%2FCatchingFire","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrackwitz%2FCatchingFire","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrackwitz%2FCatchingFire/lists"}