docs icon indicating copy to clipboard operation
docs copied to clipboard

F# documentation for NUnit has several mistakes

Open interrupt-routine opened this issue 7 months ago • 4 comments

At https://docs.codewars.com/languages/fsharp/nunit#tests :

  • Challenge should not be opened as it pulls in all of the user's symbols into the tests, which can lead to conflicts/cheating. It is enough to write UserModule.userFunction to call the user's function (open is similar to C#'s using)
  • the order of arguments in Assert.AreEqual() is wrong, it should be Assert.AreEqual(expected, actual), as usual in NUnit
  • the optional message in 3rd parameter to AreEqual() could be described

interrupt-routine avatar Apr 25 '25 13:04 interrupt-routine

Maybe the example could not use AreEqual at could be changed to Assert.That? This would future-proof the docs for the time when F# would be updated to NUnit 4, like C# was?

hobovsky avatar Apr 25 '25 14:04 hobovsky

Oh, sure, I was not aware that fluent assertions were available for F# 6.0 already, as the .NET version seems different than the one for the C#12 language version

interrupt-routine avatar Apr 25 '25 14:04 interrupt-routine

I would have to check exactly, because I am not sure at the moment but fluent assertions have been available in NUnit for some quite time already, and they are definitely available in NUnit 3, they are just not mandatory. In NUnit 3, you can use classic assertions and fluent assertions, whichever you prefer. The thing is that NUnit 4 deprecates classic assertions and prefers Assert.That, and if we start using fluent assertions in NUnit 3, we won't have to update anything after migrating to NUnit 4.

hobovsky avatar Apr 25 '25 14:04 hobovsky

You're right, I mixed up the deprecation of old-style assertions with the introduction of fluent assertions. Let's go for the new style in the F# docs then.

interrupt-routine avatar Apr 26 '25 11:04 interrupt-routine