haf / expecto

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

Q: specific reason for extra unit value in tests #284

Closed stijnmoreels closed 6 years ago

stijnmoreels commented 6 years ago

Hi,

Just a question: why have some test-function an unecessary unit value in their parameters?

Example:

testParams 10 [
    "first sample", fun v () -> Expect.equal v 10 "should be equal 10"

Is this because the testCase is defined as a function, and we need another input? The setup of the testFixture is also using this way of wrting:

testList "fixture" [
    let withMemoryStream f () =
      use ms = new MemoryStream ()
      f ms
    ...
  ]

Thanks in advance!

AnthonyLloyd commented 6 years ago

I think it's because the way it's been written it need to apply the parameter and be still left with a function it can call. There are other ways of achieving this without needing this though e.g. (fun () -> withMemoryStream xx).

stijnmoreels commented 6 years ago

And can this detail be abstracted away? Meaning, we internally wrap it in such a factory function?

AnthonyLloyd commented 6 years ago

Yes but it'd be a breaking change. I'm not sure how often these functions are used. I don't use them personally. It's easy to use functional code instead of them.