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

fix: Expect.equal error when actual is null. #289

Closed kleidemos closed 5 years ago

kleidemos commented 5 years ago

FSharpType.IsRecord(a.GetType(), BindingFlags.Default) when a = null

testProperty "json >> domain = id" <| fun value -> 
    value
    |> json
    |> domain<string A>
    |> Expect.equal "" value

[16:04:00 DBG] Compact Single DU/json >> domain = id starting... <Expecto>
[16:04:00 ERR] Compact Single DU/json >> domain = id failed in 00:00:00.0180000.
Failed after 12 tests. Parameters:
        A null
Result:
        Exception
  System.NullReferenceException: Object reference not set to an instance of an object.
   at System.Object.GetType()
   at Expecto.Expect.equal$cont@264[a](a actual, a expected, String message, Object e, Object a, Unit unitVar) in C:\Users\Anthony Lloyd\src\expecto\Expecto\Expect.fs:line 265
   at Microsoft.FSharpLu.Json.Tests.SingleDu.tests@48-2.Invoke(A`1 value) in D:\Users\Klei\Source\Repos\Rosdex-ML\tests\Rosdex.Services.Core.Tests\Microsoft.FSharpLu.Json.Tests.fs:line 52
   at FsCheck.Testable.evaluate[a,b](FSharpFunc`2 body, a a)
Focus on error:
        etestProperty (268740765, 296522512) "json >> domain = id" <Expecto>```
AnthonyLloyd commented 5 years ago

Great thanks