Skip to content

q231950/rorschach

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 understood in case of a failure.

Corresponding test result in Xcode'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.