5
m0v3
7y

!rant && seekGuidance
Been coding for 8 years now, working for at least 6-7 ( freelancing mostly ). Have done multiple big projects along the way, and have not written a single test case ever. Everything works just fine, I usually test things alongside coding stuff. Could someone explain the benefits of creating tests? You can slap me in the face for not doing it if you want ( after explaining why it's so bad ). btw, i'm a web developer ( symfony / angular / vue )

Comments
  • 2
    I used to think tests were stupid, because I used to think you just write more code to verify that other code works (but what if you have bugs in your tests). And to a degree I was right about that to the degree that there are useful and useless tests.

    But what tests are definitely good for is to detect regression. Say you have a bunch of tests which test every feature in you project for if it works. Whenever you break something (or someone else) your tests detect it.
  • 2
    And basically all a test is, is a comparison between the output of your current build and the output it gave when you decided it was "working".

    A good example is a parser. You have some input that it should parse, and you work on it until it gives the output you want. Then you save that output as the "expected output" for that input. write a script to compare the actual output of the parser when given the test input with the expected output and you got yourself a test. when the output is suddenly different than when you created the expected output, something changed.
  • 0
    Hmmm. I see your point, automated retesting after some changes could really save you sometimes. But other than that, if, for example, you work alone. And you know that you tested the code you changed/added after every iteration yourself. As, when you work, you make sure that the things you add work properly, you don't just change a bunch of things and push it to prod. Is it really worth it to also write a test?
  • 0
    Not to forget writing „testable“ code gives cleaner code... just my 2 cents...
  • 0
    @m0v3
    I suppose I share your point of view in most respects, I dont have any tests for my private project either, and I often said that a good programmer should know how his changes affect the code. But I got to understand that there are many good reasons for tests, especially when working with other people. But even when you are working alone on a big project they can save you a lot of work.
Add Comment