Nimble v3.1.0
This is a bug fix + feature addition release. Thanks to @jwfriese for the work in this release.
Note that this release does not include a pre-built binary for Carthage. Xcode doesn't gaurantee binary compatibility for pre-built frameworks. See more details: Carthage/Carthage#924.
On to the changes...
New Matcher: || (aka - satisfyAnyOf)
Matchers can be combined using the ||
operator:
expect(value).to(equal(2) || equal(3))
This expects value
to be either 2 or 3. Using ||
can be useful in complex expectations or integration tests, where less-specific expectations are usually utilized.
Warning: Conditionals in expectations are generally considered bad practice. Using ||
is a form of conditional that weakens the strength of the assertion. This matcher should be used sparingly if at all.
Updated Matcher: Equals + Optional Collections
Equals now supports optional collections:
let a: [String?] = ["a", "b", nil]
let b: [String?] = ["a", "b", nil]
expect(a).to(equal(b))
Previously, the above code caused a compiler error. Now this will work like non-optional collection types.
Asynchronous Expectations
Async expectations have been rewritten to reduce flakiness. The public API remains the same but uses lower-level features to avoid complex interactions with common run loop features.
Async expectations are any waitUntil
or expect(..).toEventually(..)
forms.
Also, Nimble emits errors on invalid usages of async expectations:
- Async expectations must be done on the main thread.
- Async expectations cannot be nested.
This is because async requires controlling the main run loop. These limitations were part of the old implementation, but left the test writer to discover them via flaky tests. The new implementation will immediately fail.