Skip to content

Commit

Permalink
Merge pull request #5 from q231950/prepare-v1-1-0
Browse files Browse the repository at this point in the history
Update documentation and tests
  • Loading branch information
q231950 authored Jun 11, 2021
2 parents 1783ccd + 14d2cd3 commit 7df0c48
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
23 changes: 18 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
<img width=800 src="Resources/rorschach.png" alt="The Rorschach Logo">


This package allows you to write tests in a BDD style. It's Swift's result builders that allow for a lightweight DSL that makes your tests way more readable.

**This package allows you to write tests in a BDD style.**

It's Swift's result builders that allow for a lightweight DSL that makes your tests way more readable.



Take a look at the following example:

```swift
func test_simple_example() {
Expand All @@ -10,18 +17,24 @@ func test_simple_example() {

expect {
Given("I have a universe without any stars") {
context.numberOfStars = 5
context.numberOfStars = 0
}
When("I add a couple of stars") {
context.numberOfStars = 1_000_000_000_023
context.numberOfStars = 23
}
Then("I can see the stars I have added ✨") {
XCTAssertEqual(context.numberOfStars, 1_000_000_000_023)
XCTAssertEqual(context.numberOfStars, 23)
}
}
}
```

Please note that the contents of each step like `context.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.

<img width=800 src="Resources/test-result.png" alt="Corresponding test result in Xcode's Report Navigator">

---

<img width=800 src="Resources/test-result.png" alt="Corresponding test result 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](https://twitter.com/q231950) or [create a new issue](https://github.com/q231950/rorschach/issues/new).
6 changes: 3 additions & 3 deletions Tests/RorschachTests/RorschachTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ final class RorschachTests: XCTestCase {

expect {
Given("I have a universe without any stars") {
context.numberOfStars = 5
context.numberOfStars = 0
}
When("I add a couple of stars") {
context.numberOfStars = 1_000_000_000_023
context.numberOfStars += 23
}
Then("I can see the stars I have added ✨") {
XCTAssertEqual(context.numberOfStars, 1_000_000_000_023)
XCTAssertEqual(context.numberOfStars, 23)
}
}
}
Expand Down

0 comments on commit 7df0c48

Please sign in to comment.