• CoderKat@lemm.ee
    link
    fedilink
    English
    arrow-up
    2
    ·
    11 months ago

    Strong typing doesn’t prevent the need for tests. It can certainly catch some issues (and I don’t like dynamically typed languages as a result), but there’s no replacement for unit testing. So much refactoring is only safe because of rigorous test coverage. I can’t begin to tell you how many times a “safe” refactoring actually broke something and it was only thanks to unit tests that I found it.

    If code is doing anything non-trivial, tests are pretty vital for ensuring it works as intended (and for ensuring you don’t write too much code before you realize something doesn’t work). Sure, you can manually test, but often manual testing can have a hard time testing edge cases. And manual testing won’t help you prevent regressions, which is usually the biggest reason to write unit tests. If you have a big, complicated system worked on by more than one person, tests can be critical for ensuring other people (who often have no idea how your code works) don’t break your test. Plus your own future changes.