fscheck / FsCheck

Random Testing for .NET
https://fscheck.github.io/FsCheck/
BSD 3-Clause "New" or "Revised" License
1.17k stars 156 forks source link

How to use Collect from async test (C#) #609

Closed jibbers42 closed 7 months ago

jibbers42 commented 2 years ago

I'm unable to return a Property from async tests. I'm not sure if the issue is more or less a missing overload in the api or if things are more complicated. Is there a way to use Collect from an async test (both assertion and bool style)?

// Assertion style
[Property]
public Property Test_async_function2() {
  return Prop.ForAll<DoNotSize<int>>(async i => {
    await Task.Delay(10);
    Assert.True(i.Item is int);
    // return true.Collect(i); // will not compile
  });
}

// Bool style
[Property]
public Property Test_async_function6() {
  return Prop.ForAll<DoNotSize<int>>(async i => {
    await Task.Delay(10);
    // return (i.Item is int).Collect(i.Item); // will not compile
  });
}

As an aside, I believe I had to update to v3 to get async tests to work and I notice a C# records fix recently landed. Will there be a v3 beta update soon? Is there a thread to track progress on when v3 will be released?

kurtschelfthout commented 2 years ago

hmm, looks like a Task<Property> overload is missing for ForAll.