{"id":13466106,"url":"https://github.com/kylef/Spectre","last_synced_at":"2025-03-25T21:31:14.677Z","repository":{"id":48581275,"uuid":"43971874","full_name":"kylef/Spectre","owner":"kylef","description":"BDD Framework and test runner for Swift projects and playgrounds","archived":false,"fork":false,"pushed_at":"2021-09-07T19:43:18.000Z","size":387,"stargazers_count":404,"open_issues_count":5,"forks_count":41,"subscribers_count":15,"default_branch":"master","last_synced_at":"2024-10-29T19:16:01.110Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kylef.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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-10-09T18:03:59.000Z","updated_at":"2024-10-26T20:45:11.000Z","dependencies_parsed_at":"2022-09-03T16:11:02.775Z","dependency_job_id":null,"html_url":"https://github.com/kylef/Spectre","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kylef%2FSpectre","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kylef%2FSpectre/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kylef%2FSpectre/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kylef%2FSpectre/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kylef","download_url":"https://codeload.github.com/kylef/Spectre/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245547269,"owners_count":20633337,"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-31T15:00:39.186Z","updated_at":"2025-03-25T21:31:14.388Z","avatar_url":"https://github.com/kylef.png","language":"Swift","readme":"# Spectre\n\n[![Build Status](https://img.shields.io/travis/kylef/Spectre/master.svg?style=flat)](https://travis-ci.org/kylef/Spectre)\n\n[*Sp*ecial *E*xecutive for *C*ommand-line *T*est *R*unning and\n*E*xecution](https://en.wikipedia.org/wiki/SPECTRE).\n\nA behavior-driven development (BDD) framework and test runner for Swift projects\nand playgrounds. It's compatible with both OS X and Linux.\n\n## Usage\n\n```swift\ndescribe(\"a person\") {\n  let person = Person(name: \"Kyle\")\n\n  $0.it(\"has a name\") {\n    try expect(person.name) == \"Kyle\"\n  }\n\n  $0.it(\"returns the name as description\") {\n    try expect(person.description) == \"Kyle\"\n  }\n}\n```\n\n### Reporters\n\nSpectre currently has two built-in reporters, Standard and the Dot reporter.\nCustom reporters are supported, make a type that conforms to `Reporter`.\n\n- Standard\n- Dot Reporter (`-t`)\n- Tap Reporter (`--tap)` - [Test Anything Protocol](http://testanything.org/)-compatible output\n\nThe default reporter can be configured via an environment variable. For\nexample:\n\n```shell\n$ env SPECTRE_REPORTER=dot swift test\n$ env SPECTRE_REPORTER=tap swift test\n```\n\n#### Standard\n\nThe standard reporter produces output as follows:\n\n##### Passing Tests\n\n![Standard Reporter Success](Screenshots/success.png)\n\n##### Failing Tests\n\n![Standard Reporter Failure](Screenshots/failure.png)\n\n#### Dot\n\nUsing the `-t` argument, you can use the dot reporter.\n\n##### Passing Tests\n\n![Dot Reporter Success](Screenshots/success-dot.png)\n\n##### Failing Tests\n\n![Dot Reporter Failure](Screenshots/failure-dot.png)\n\n### Expectation\n\n#### Equivalence\n\n```swift\ntry expect(name) == \"Kyle\"\ntry expect(name) != \"Kyle\"\n```\n\n#### Truthiness\n\n```swift\ntry expect(alive).to.beTrue()\ntry expect(alive).to.beFalse()\ntry expect(alive).to.beNil()\n```\n\n#### Error handling\n\n```swift\ntry expect(try write()).toThrow()\ntry expect(try write()).toThrow(FileError.NoPermission)\n```\n\n#### Comparable\n\n```swift\ntry expect(5) \u003e 2\ntry expect(5) \u003e= 2\ntry expect(5) \u003c 10\ntry expect(5) \u003c= 10\n```\n\n#### Types\n\n```swift\ntry expect(\"kyle\").to.beOfType(String.self)\n```\n\n#### Causing a failure\n\n```swift\nthrow failure(\"Everything is broken.\")\n```\n\n#### Custom assertions\n\nYou can easily provide your own assertions, you just need to throw a\nfailure when the assertion does not meet expectaions.\n\n## Examples\n\nThe following projects use Spectre:\n\n- [Commander](https://github.com/kylef/Commander)\n- [Stencil](https://github.com/stencilproject/Stencil)\n\n## Installation / Running\n\n### Swift Package Manager\n\nCheck out [Commander](https://github.com/kylef/Commander) as an example.\n\n### Playground\n\nYou can use Spectre in an Xcode Playground, open `Spectre.playground` in\nthis repository, failures are printed in the console.\n\n![Spectre in an Xcode Playground](Screenshots/Playground.png)\n","funding_links":[],"categories":["Libs","Testing [🔝](#readme)","The Index"],"sub_categories":["Testing","Graphics"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkylef%2FSpectre","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkylef%2FSpectre","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkylef%2FSpectre/lists"}