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

use of runTestsWithCLIArgs differs between Expecto and Expecto.Flip #472

Closed sporring closed 8 months ago

sporring commented 11 months ago

Hi, I'm considering using Expecto to teach 1st year computer scientists how to perform tests. I noticed that runTestsWithCLIArgs behaves differently in Expecto and Expecto.Flip. Using a variant of the demo example in README.md, in interactive mode the following works:

open Expecto

let simpleTest =
  testCase "A simple test" <| fun () ->
    Expect.equal 4 (2+2) "2+2 = 4"

runTestsWithCLIArgs [] [||] simpleTest

but it doesn't when using Expecto.Flip, in which case the tests must be gathered as test:

open Expecto
open Expecto.Flip
let simpleTest =                    
    (2+2)|>Expect.equal "2+2 = 4" 4

test "" {simpleTest} |> runTestsWithCLIArgs [] [||]

Is there a deeper rationale behind this difference? Thanks, Jon

farlee2121 commented 11 months ago

I'm not sure what error you're running into. The behavior seems the same to me.

This works

open Expecto
open Expecto.Flip
let simpleTest =
  testCase "A simple test" <| fun () ->                    
    (2+2) |>Expect.equal "2+2 = 4" 4

simpleTest |> runTestsWithCLIArgs [] [||]

Only Expect methods have flip variants, and all they do is accept parameters in reverse order then forward them to the non-flipped version.

Perhaps you accidently removed the testCase "A simple test" <| fun () -> line when you tried rewriting for Expecto.Flip?

Edit: I ran these samples using interactive notebooks