10

Is it just me, or are unit tests just overrated?

Comments
  • 6
    just you.
    jk: i thought the same in the beginning, but that was because I was doing it wrong. Nowadays i really appreciate it and actually like writing tests.
    But the important part: do them before you actually implement the stuff.
  • 7
    Functionality testing is a must have in more complex programs. It is especially useful when doing web development where a small change could often break something you wouldn't think of thanks to the type handling of JS and PHP.
  • 4
    Im just starting out but I don't see why they are useless. They might be in a project of 500 lines. But in a project with 50 files multiple controllers they cannot be missed
  • 4
    @Codex404 i do it even with small 500 loc projects. It saves my day, when I add feature b and notice that because of that the already implemented feature a breaks, because of the changes. And that during the development process, which means less pain afterwards.
  • 3
    @plusgut indeed, but a 500 lines project is normally still something which can be tested pretty easily by hand.
  • 1
  • 0
    If you feel that they are unnecessary or you dont have a legit reason to implement them.. They probably are overrated for your project. For example, im not sure that for a small startup it will be a wise idea spending time in those when you need functionality that might lead to money..
  • 3
    Unit tests are super valuable, but not everything is unit-testable. I've worked with managers and CTOs that think that the codebase needs 100% unit test coverage.

    Well that just doesn't make sense. Unit test your model classes and atomic entities that make sense to be tested in isolation. When you have to start writing test harnesses and test stubs, or adding dependency injection just so you can stub out real classes for test proxies, that's when it starts getting real messy and now you're actually introducing more chance of bugs just to make your software testable.
  • 1
    @devios1 a colleague of my who was on a project for a dutch tv station did have 100% coverage for their website.
    But normally its about 90% right?
  • 1
    @Codex404 Websites are a bit different because you can actually script user interface interactions, which means in some cases you can actually get 100% coverage. Usually user interfaces are not easily unit testable though on other platforms. I can't say what a typical code coverage is.
  • 1
    @kaqqao unit tests dont only test functions but also helps as documentation on how a certain piece of code has to work, what it does and types it expects.
  • 0
    I, on the other hand, could not appreciate DOM / GUI testing. Automating the clicks? There are so many cases to consider. Enlighten me, masters.
  • 1
    @nikolatesla I think that no method is perfect... The different possibilities just grow exponentially in most GUI. But testing a lot of user cases can already help a lot. Creating a test doesn't take much time, but if you do something wrong, you will know it before putting it on the master branch/on production :)
    If you do correct unit tests on all the functions that need it, you will also reduce errors.
  • 2
    @nikolatesla I've never done it myself but if MDN would do gui tests to see if every link works the website would be much more usable.
Add Comment