Swiftpack.co - q231950/rorschach as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by q231950.
q231950/rorschach v2.0.0
Write XCTests in BDD style 🤷🏻‍♂️
⭐️ 54
🕓 1 year ago
.package(url: "https://github.com/q231950/rorschach.git", from: "v2.0.0")
The Rorschach Logo

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:

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 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 undsrc="https://raw.github.com/q231950/rorschach/main/od in case of a failure.

<img style="max-width:100%;" width=800 src="Resources/test-result.png" alt="Corresponding test result src="https://raw.github.com/q231950/rorschach/main/ode's Report Navigator">

Corresponding test result with failure in Xcode's Report Navigator

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 or create a new issue.


Stars: 54
Last commit: 3 weeks ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

Colorful Tone
1 year ago

This release refines the public API.

  • makes the expect function part of an extension on XCTest
  • adds documentation
  • refactors production and test code
  • compiles on Xcode 14 Beta 1 and Beta 2
  • compiles with swift-tools-version:5.7

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics