You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's very common to use packages like testify or is as a set of helper methods that make testing code more readable. The reason behind using packages like that is to avoid writing repetitive code like the following.
Using generics has a big benefit over using any - we have a compile-time type check.
I know that saving those 2 lines of code doesn't seem to be a big win but please remember that the code may be repeated many times in a single test file.
The text was updated successfully, but these errors were encountered:
It's very common to use packages like testify or is as a set of helper methods that make testing code more readable. The reason behind using packages like that is to avoid writing repetitive code like the following.
The
if
statement with the error message can be repeated even a hundred times. That's why we use external libraries to avoid that.As we have generics in the language, we can make use of it and provide a new method in
testing.T
andtesting.B
:The first snipped would be simplified into:
Using generics has a big benefit over using
any
- we have a compile-time type check.I know that saving those 2 lines of code doesn't seem to be a big win but please remember that the code may be repeated many times in a single test file.
The text was updated successfully, but these errors were encountered: