|
|
|
|
|
by crtc
1922 days ago
|
|
> with types you need way less unit tests It's a misconception that developers who use dynamically typed programming languages write tests that perform tasks of a static type system. They do not write tests like this: assertException(() => upcase(12));
assertException(() => upcase(true));
assertException(() => upcase(null));
assertException(() => upcase(new Object()));
...
They write tests like assertEquals("TEST", upcase("test"));
assertEquals("HELLO, WORLD", upcase("hElLo, wOrLd"));
assertEquals("BLA123", upcase("bla123"));
|
|
Those tests that you list later are "happy path" tests. We want to know that that works, but we can't rely on only that sort of test especially if the type system doesn't work with us to avoid incorrect inputs to the function.