FsUnit.Xunit : when using result type, on error, actual message is not showing the pretty printing but type info.
See original GitHub issueDescription
When the unit test “should equal” failed, an error message indicates the pretty printing for the Expected but only type info the the Actual one.
Repro steps
-
Add the FsUnit.Xunit
-
add a unit test with :
Ok "hello" |> should equal (Ok "world")
Expected behavior
Expected result :
FsUnit.Xunit+MatchException: Exception of type 'FsUnit.Xunit+MatchException' was thrown.
Expected: Equals Ok "world"
Actual: Equals Ok "hello"
Actual behavior
FsUnit.Xunit+MatchException: Exception of type 'FsUnit.Xunit+MatchException' was thrown.
Expected: Equals Ok "world"
Actual: was Microsoft.FSharp.Core.FSharpResult`2[System.String,System.Object]
at FsUnit.Xunit.Assert.That.Static[a](a actual, IMatcher`1 matcher) in /Users/sergey/github/FsUnit/src/FsUnit.Xunit/FsUnit.fs:line 19
at FsUnitBench.AssertBug.result bug() in C:\gh\UnitTestingBenchmark\FsUnitBench\AssertBug.fs:line 9
Known workarounds
let private pretty x = sprintf "%A" x
let shouldBe (expected:'a) (actual:'a) =
if expected <> actual then
raise (Xunit.Sdk.EqualException(pretty expected, pretty actual))
Related information
- Operating system
- Branch
- .NET Runtime, CoreCLR or Mono Version
- Performance information, links to performance testing scripts
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:5 (5 by maintainers)
Top Results From Across the Web
F# XUnit test does not print output
I got output to appear without a failing test by using Console. ... WriteLine message type StackOverflow(output : ITestOutputHelper) = do ...
Read more >Review: F# unit testing frameworks and libraries
A review of XUnit, FsUnit, Unquote, and Expecto as unit testing ... makes use of a cool F# language feature to give detailed...
Read more >What is FsUnit?
FsUnit is a set of libraries that makes unit-testing with F# more enjoyable. It adds a special syntax to your favorite .NET testing...
Read more >Idiomatic way to write proper F# (x)unit + fsunit tests?
I am writing some unit tests using XUnit in F# and I am wondering what is the most idiomatic way in the F#...
Read more >List of unit testing frameworks
Name xUnit TAP Fixtures Group fixtures Generators License
AceUnit Yes Yes BSD License
AcuTest Yes Yes MIT
API Sanity Checker Yes Yes (spectypes) Yes (spectypes) Yes...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Fixed with #155.
I opened a PR #155 which will fix the “ugly” message. Xunit and MsTest messages were affected.