Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/q231950/rorschach
Write XCTests in BDD style 🤷🏻♂️
https://github.com/q231950/rorschach
bdd bdd-style swift-function-builders swift-result-builders testing uitest unittest xctest
Last synced: about 1 month ago
JSON representation
Write XCTests in BDD style 🤷🏻♂️
- Host: GitHub
- URL: https://github.com/q231950/rorschach
- Owner: q231950
- License: apache-2.0
- Created: 2020-03-21T20:56:42.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-01-28T19:00:58.000Z (11 months ago)
- Last Synced: 2024-08-02T08:10:01.070Z (4 months ago)
- Topics: bdd, bdd-style, swift-function-builders, swift-result-builders, testing, uitest, unittest, xctest
- Language: Swift
- Homepage:
- Size: 475 KB
- Stars: 55
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-result-builders - Rorschach - Write XCTest tests in BDD style 🤷🏻♂️ (Testing)
README
**This package allows you to write XCTest tests in a BDD style.**
Similar to Swift Regex and SwiftUI it's Swift's result builders that allow for a lightweight DSL that can make your tests way more readable.
Take a look at the following example:
```swift
func test_simple_example() {let universe = UniverseContext()
expect {
Given("I have a universe without any stars") {
universe.numberOfStars = 0
}
When("I add a couple of stars") {
universe.numberOfStars = 23
}
Then("I can see the stars I have added ✨") {
XCTAssertEqual(universe.numberOfStars, 23)
}
}
}
```Please note that the contents of each [Step](Sources/Rorschach/Step.swift) like `universe.numberOfStars = 23` for example, are arbitrary Swift code - you are free to add your abstractions on a Page Object Model or the like as you need them.
The test run leads to this result in Xcode's Report Navigator. An easy to read output that can easily be understood in case of a failure.
---
Contributions are much appreciated. Any kind of feedback about whether or not this is helpful for you or if you want to share ways to improve _Rorschach_ are highly welcome. Reach out on Twitter to [q231950](https://twitter.com/q231950) or [create a new issue](https://github.com/q231950/rorschach/issues/new).