I can't get toEventually to work correctly after updating to Nimble 11.x
marcinpodeszwa-medcase opened this issue · comments
- I have read CONTRIBUTING and have done my best to follow them.
What did you do?
Consider following sample code:
class Sample {
static var executed = false
func execute() {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
Self.executed = true
}
}
}
I want to test it using Quick+Nimble, so I wrote following test:
class SampleTests: QuickSpec {
override func spec() {
describe("Sample") {
it("sets executed") {
Sample().execute()
expect(Sample.executed).toEventually(beTrue())
}
}
}
}
And it was working perfectly well on Quick 5.0.1 and Nimble 10.0.0
After updating Quick to 6.0.0 and Nimble to 11.1.0 I saw this warning (but the test was passing):
I added keyword await
(that's what I thought I need to do) and suddenly my test stopped passing:
What did you expect to happen?
I expect this test to pass without warnings. Maybe there is something I don't understand, because I'm new to new swift's concurrency.
What actually happened instead?
Depending on if I add await
or not, I get either a warning or a test failure.
Environment
List the software versions you're using:
- Quick: 6.0.0
- Nimble: 11.1.0
- Xcode Version: Version 14.1 (14B47b) (Open Xcode; In menubar: Xcode > About Xcode)
- Swift Version: 5.7.1 (Open Xcode Preferences; Components > Toolchains. If none, use
Xcode Default
.)
Please also mention which package manager you used and its version. Delete the
other package managers in this list:
- Swift Package Manager 5.7.1 (Use
swift build --version
in Terminal)
Project that demonstrates the issue
Please link to a project we can download that reproduces the issue. Feel free
to delete this section if it's not relevant to the issue (eg - feature request).
The project should be short, self-contained, and correct example.
Hey, thanks for the succinct bug report with reproducible sample!
The Self.executed = true
line is getting executed. The static var is getting set. But it appears that Nimble is sending a cached value to the matcher?
Oops. I forgot to use uncachedExpression
in the async-compatible version of toEventually.
This fix is included in the just-released v11.1.1!
thanks @younata , works great now!