Do you follow test driven development?

  • 70
    Nope. But in TDD, you will write a code that will check the code that you “will” write.
  • 16
    I love TDD. It's slow at the beginning, but it makes your code really stable
  • 20
    @masterlei yeah true. This joke is taking it to a deeper level. Write test cases to validate the test you wrote 😂
  • 7
    Yeah... In my current project, the first thing I did was translate the concept to RSpec tests - the first time I ever did that.
    Turns out real well, MVP in 5 days...

    Then the project manager changed every fucking little detail, back and forth like a racoon on Crack...

    Yeah, after that and with the time pressure on, TDD my ass it was. Again.

    Guess a certain Project manager needs a beating.
  • 4
    Nope. My coding is too ad-hoc and unplanned to do that.

    But we have used sonarqube and for the fun of it we enabled it for test projects too. As a result the coverage went down because the tests weren't covered by tests. Off to write tests for the tests and the cycle begins anew.
  • 5
    yeah, just write a test that always passes
  • 7
    Too bad lots of the tools for TTD are still terrible and require lots of repetitive code to work. It should not require 75% of my time
  • 2
    It should be done by machines :/
  • 3
    Writing tests is hard. I don’t think, you can ever go below 30%. Especially, when you start a new module/project, you spend a lot of time setting the test framework up. BUUUUT In most projects, 75% of your time is worth less than the cost of multiple people reporting, coordinating and fixing a stupid bug.
    Any experienced software manager will prefer slower developer over a fast one who produces a lot of problems.

    I like to write tests, because the first junior who touches my code in the future will break it and this will be my fault.
  • 5
    Tests are usaully much simpler programs than the program being tested. So there is really much less chance to introduce and then miss a bug in the tests entirely and good tests are really really useful. You might think writing tests takes up 75% of your work but thats just because without writing tests you would spend a lot more time with manual testing and debugging.
  • 0
    @simulate how often do you use it? What framework?
  • 1
    We always write at least some experience-based tests. No framework, its really not that complicated...
    Say you want to test a function/program, first you just make up some input data and define the expected result (return value, check some variable, threw exception?) and then you write a tiny program (the test) which calls that function with the input parameters and if what happens matches the expected result, the test passes. Then you probably want some script which runs all of your test programs after each build so that you catch bugs as soon as they occur.
  • 1
    I feel the same way when manager asks me to write test cases to test "flow of code(his words) "... I use mokito, but sometimes hate this part of my job! 😑
  • 6
  • 1
  • 0
    If you do t write tests how can you release something without shooting bricks for the next week solid from nerves?
  • 0
    That’s not how it works. That’s like... the opposite of how it works.
  • 1
    @masterlei ugh beat me to it
  • 0
    EVERY time I considered doing real TDD, this thought entered my head and I just couldn’t bring myself to do it.
  • 0
    I mostly don't follow TDD strictly, but I strongly believe that writing tests should be a fundamental task for every professional software developer.
    Why? Because it will enable you to refactor your code, and to add new functionality without breaking things. So, adding tests (and, mind you, _fast_ tests) is an investment in the quality of your product.

    Having said that, adding tests for trivial functions is a waste of time. In addition, enforcing a certain threshold for the test coverage is stupid and may in fact be harmful.

    Regarding "testing your tests": mutation testing is what you should do ;)
  • 0
    TDD: first write the test and den implement
  • 0
    Most of the checking actually is done by the compiler - if your code is in OCaml...
  • 0
    Yep has made refactoring a dream and classes small
  • 0
    I have been trying to figure out if there's a way to train an AI model to write tests for me as I write out my APIs. Anybody else who's tried this?
Add Comment