Allow asynchronous tests to run on Task<'a>
See original GitHub issueThat FsCheck can run asynchronous tests is one of its major advantages over competitors. It’d be nice, however, if it could run methods/actions that return Task<'a>
instead of simply Task
.
Particularly, with the new task
computation expression, one can easily write an asynchronous (integration) test, but even if such a test body ends with an assertion, the expression has the type Task<unit>
, rather than Task
.
One can get around this issue by upcasting the expression with :> Task
. If, however, one wishes to avoid adding an extra line of code for only that purpose, one runs into this issue.
If, currently, one tries to pass a Task<unit>
to Prop.forAll
if compiles fine, but fails at run time with this error message:
No instances of class FsCheck.Testable+ITestable`1[T] for type System.Threading.Tasks.Task`1[Microsoft.FSharp.Core.Unit]
This is on FsCheck.Xunit 3.0.0-beta2.
Since Task<'a>
derives from Task
is seems to me that a fix should be a fairly straightforward.
If you agree that such a fix is desired, I may try my hand at it myself. (I’ve been away from contributing to FsCheck for years, now, so I hope I’m not biting off more than I can chew.)
Issue Analytics
- State:
- Created 3 months ago
- Comments:8 (7 by maintainers)
Top GitHub Comments
Released in 3.0.0-rc1.
Also merged fscheck3 branch to master.
@bartelink yes, I think it’s time for that. I’ll probably just do
3.0.0
even. If the other plans ever materialize, there’ll just have to be another version.