3 ms·
Define "one thing" Suppose you want to test a function that capitalizes the first letter of words in a string: I would test '' => '' 'a' => 'A' 'aa bb' => '
by raverbashing 10y ago
Define "one thing"
Suppose you want to test a function that capitalizes the first letter of words in a string: I would test
'' => ''
'a' => 'A'
'aa bb' => 'Aa Bb'
3 tests, which does not mean 3 functions (that will have the overhead of setup and teardown)
- flukus 10y agoI would make this a parameterized test for those common use cases and specific test for others ("o'tool" => "O'Tool"). The overhead of setup/teardown should be practically zero. Even having them as 3 separate functions should be take fractions of a millisecond. The important thing is, it should be obvious why a test failed, you don't want more then 1 or two asserts.