Spectre
Spectre copied to clipboard
Testing async methods
Hi, @kylef
I want to test some async methods. Is it now supported in Spectre?
I just had a brief look at Spectre but didn't find this feature. Maybe something like this in other BDD testing framework:
$0.it("should do something asynchronously") {
waitUntil { done in
//.. async work
done()
}
}
If this is not yet in Spectre, I'd like to try to implement (although I have no experience on creating a test framework). Before I could get into it, I think it's better to confirm it. What do you think about it?
This will depend on how the work is ran, i.e, if you are using Cocoa, libuv, or lib dispatch etc. You will need to write some "wait" function which will block until the event happens in your specific run loop.
Adding to this, it would be neat to make an extension for it which accepts returning a promise/signal or similiar to wait for. Shouldn't be too hard to integrate into any particular event loop used.