question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature]: Make assertions with 'because' parameter more friendly to F#

See original GitHub issue

Background and motivation

I love FluentAssertions and use it for F#. However, F#'s overload resolution is different than that of C#. One effect is that all overloads with because and becauseArgs require specifying because. For example,

result.Should().BeNull()

will not compile. Instead, it is required to write

result.Should().BeNull("")

This makes all assertions in F# more noisy. This is particularly noticeable for assertions that use a lambda parameter before because, since then the lambda is not the last argument and it then requires extra parentheses.

I suggest adding overloads for all assertions that do not have because or becauseArgs. That will allow F# users to assert without having to specify empty strings everywhere.

While I cannot promise anything, I may be willing and able to do a one-time pass of the codebase and add these overloads (at least as long as you don’t see the need for separate tests and the overloads can just call existing overloads with an empty string argument). I can not prioritize adding and maintaining such overloads for all future assertions, but the additional work involved is trivial when new assertions are added.

Alternative Concerns

No response

Issue Analytics

  • State:closed
  • Created 3 months ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
cmeerencommented, Jul 17, 2023

Thanks for the offer!

I find that FluentAssertions.FSharp makes it sound like an add-on to FluentAssertions, which it’s not. Indeed, in focusing towards F# users and their expectations and idioms, the library will actively take a step away from FluentAssertions in some respects (dropping/adding/changing functionality). Therefore, I’m leaning toward sticking with the current name, “Faqt”. In any case, my main motivation for OSS projects has never been getting the most users (though I of course want people who want/need it to know about it). Furthermore, if I get it posted on F# Weekly (which is just a tweet away), then I think that will be all the focused marketing I need.

FluentAssertions is however welcome to point F# users to Faqt! 🙂

1reaction
jnyrupcommented, Jul 15, 2023

Good idea to make a new library to improve the usage the usage for F# users 👍 It could even be an F# library with a name like FluentAssertions.FSharp or FluentAssertions.FSharpPolyfills.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Programming With Assertions
An assert is inappropriate because the method guarantees that it will always enforce the argument checks. It must check its arguments whether or...
Read more >
Python's assert: Debug and Test Your Code Like a Pro
In this tutorial, you'll learn how to use Python's assert statement to document, debug, and test code in development.
Read more >
How to assert an actual value against 2 or more expected ...
I'm testing a method to see if it returns the correct string. This string is made up of a lot of lines whose...
Read more >
Assertion functions in TypeScript
Let's explore assertion functions in TypeScript and see how they can be used to express invariants on our variables.
Read more >
Make assert() macro user friendly for C and C++
The assert() macro, being a macro, is not very beginner friendly in C++, because the preprocessor only uses parenthesis for pairing and none...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found