SwensenSoftware / unquote

Write F# unit test assertions as quoted expressions, get step-by-step failure messages for free
http://www.swensensoftware.com/unquote
Apache License 2.0
285 stars 26 forks source link

Default output for DateTime comparisons can be confusing #155

Closed thednaz closed 3 years ago

thednaz commented 3 years ago

The following test will fail, since the DateTime values will be slightly different.

let ``Test`` =
    let actual = DateTime.UtcNow
    let expected = DateTime.UtcNow

    test <@ actual = expected @>`

The exception output:

actual = expected
10/13/2020 9:36:09 PM = 10/13/2020 9:36:09 PM
false
Expected: True
Actual:   False

The issue is, the default output formatting will show the times to be the same, which has confused people. Can default output formats for certain types be overriden, to make the reason for this type of test failure very clear? Or is there another workaround that you can suggest?

stephen-swensen commented 3 years ago

Hi - I think we can improve the default output to include higher precision. Unquote doesn't expose a way for user's to override formatting currently.