Tests communicate a lot of information, to readers, other developers, and even our future selves. Well-written tests focus on a single unit of behaviour that can be described in a brief sentence, and we can use that sentence as the name of the test.
Almost always use parameterized style tests, always have a name field, I don’t use full sentences tho, that seems like too much. Don’t believe I’ve ever seen a test like that either
I’ve seen codebases that had old testValid2 style of test as well as fully fleshed out conversionReturnsNullOnEmptyString style. Working there made me apreciate proper naming. I know different test frameworks in different languages let you name the test separately, but it’s a bit of an effort duplication.
I get what your saying, we’ve all worked in terrible code bases, i’ve also worked in code bases where this kind of article was enforced. What you wound up with was something that was very wordy.
Almost always use parameterized style tests, always have a name field, I don’t use full sentences tho, that seems like too much. Don’t believe I’ve ever seen a test like that either
These toy examples feel like strawmen to me
I’ve seen codebases that had old
testValid2
style of test as well as fully fleshed outconversionReturnsNullOnEmptyString
style. Working there made me apreciate proper naming. I know different test frameworks in different languages let you name the test separately, but it’s a bit of an effort duplication.Go has an idiom like so https://github.com/hashicorp/vault/blob/8da4386caceb3fdfaa90074bb29c77e8a99c7dad/api/kv_test.go#L27, when i mention name i’m referring to that string.
I get what your saying, we’ve all worked in terrible code bases, i’ve also worked in code bases where this kind of article was enforced. What you wound up with was something that was very wordy.