haf / expecto

A smooth testing lib for F#. APIs made for humans! Strong testing methodologies for everyone!
Apache License 2.0
663 stars 96 forks source link

Add `testFixtureAsync` for asynchronous test fixtures #437

Closed stijnmoreels closed 1 year ago

stijnmoreels commented 1 year ago

Expecto is so great and extensible that you are able to create your own composition that works for your test. I even wrote about this beautiful paradigm in this blog post: https://www.codit.eu/blog/the-beautiful-f-expecto-paradigm-think-in-tests-not-frameworks/ So, great job and thx for this super library! 🧡

Using Expecto in integration tests poses the question for asynchronous test fixtures. Currently, test fixtures can only be created synchronously, but there are cases where you would want to setup/teardown asynchronously, for example a Giraffe application that is setup/teardown for each integration test.

An implementation is easy to create yourself, so not sure if this is so usable to be added. Just a proposition.

let inline testFixtureAsync setupAsync =
  Seq.map (fun (name, partialTest) -> 
    testAsync name { do! setupAsync partialTest })