I am trying to write a unit test using Quick/Nimble that tests an async function, as per the Nimble documentation:
await expect(await aFunctionReturning1()).to(equal(1))
Unfortunately this line does not compile for me.
Environment:
- Xcode 14.2
- Quick 6.1.0
- Nimble 11.2.1
- Test in a Swift Package
A minimal reproducable example is this:
import Quick
import Nimble
struct Foo {
func bar() async -> String {
await Task { "Hello World" }.value
}
}
final class FooSpec: QuickSpec {
override func spec() {
describe("A Foo") {
describe("When calling Bar") {
var foo: Foo!
beforeEach {
foo = Foo()
}
it("Says Hello World") { await expect( await foo.bar()) == "Hello World" }
}
}
}
}
This leads to 'async' call in an autoclosure that does not support concurrency
, and another warning I do not understand:
What am I missing?