adamchester / expecto-adapter

Visual Studio test adapter for Expecto (https://github.com/haf/expecto)
MIT License
28 stars 16 forks source link

`Expect.isFasterThan` result is shown both as red and green #14

Closed vasily-kirichenko closed 7 years ago

vasily-kirichenko commented 7 years ago

Having this code:

open Expecto
open System
open System.Threading
open System.IO

[<Tests>]
let tests =
    testList "Simple tests" [
        test "Simple" { Expect.containsAll [0; 1; 3; 2] [1; 2] "foo" }
        testCase "One" <| fun _ -> Expect.equal (1 + 1) 2 (sprintf "%d + %d = %d" 1 1 2)

        test "Perf" { 
            Expect.isFasterThan (fun () -> Thread.Sleep 90) (fun () -> Thread.Sleep 100) "Perf"
        }

        test "Perf" { 
            Expect.isFasterThan
                <| fun _ -> [1..1000] |> List.sortDescending |> ignore
                <| fun _ -> [|1..1000|] |> Array.sortDescending |> ignore
                <| "Sorting lists is faster than sorting arrays?"
        }

        test "t" {
            Expect.throwsT<FileNotFoundException> 
                <| fun _ -> raise (FileNotFoundException())
                <| "wow"
        }
    ]

[<EntryPoint>]
let main argv = 
    runTestsWithArgs defaultConfig argv tests |> ignore
    Console.ReadKey() |> ignore
    0

The result is somewhat confusing:

1

image

nikolamilekic commented 7 years ago

@vasily-kirichenko So you defined two tests that are both called "Perf": one passed and the other failed and that is what is being shown. What are your expectations and what am I missing here?

vasily-kirichenko commented 7 years ago

@nikolamilekic yellow? ;) Sorry, I was stupid.