DEV Community

Discussion on: What are your thoughts on testing and TDD?

Collapse
 
phantas0s profile image
Matthieu Cneude • Edited
  • Testing is mandatory.
  • Manual testing takes time and is painful, because you need to test everything again after changing anything, so it should be avoided. Many thinks that it's faster than automated testing, but it's not true.
  • Coding is not only typing code. It needs to make sense. Automated testing is not only testing. It needs to make sense. If it doesn't, it's not because of the test, but of the person who types.
  • If you spend too much time on your test, you're not efficient enough. You can fix that. The problem is not the tests.
  • If tests are not written early in the project:
    • Nobody will tests because "nobody tested before".
    • It's way, way more difficult to introduce tests to code which is not designed to have tests.
  • TDD is not a religion, and it has many flavors. Not only the red-green-refactor one.
  • TDD is not important. Writing good tests is. What is good tests? Doesn't break each time you change something, test what's important for your precise project.
  • Refactoring is the most important part.
  • TDD doesn't (shouldn't) drive a design. TDD doesn't know anything about what your company wants to do with the software, what the business constraints, what the invariant (stuff which doesn't change) you need to respect. Think, before using easy recipes.
  • Use whatever you need in your precise context. If you have mostly data from outside, TDD won't really help you (good luck to unit test external APIs...), for example.
  • It's not because your app still fail in production that your tests are useless. You don't see every bug you avoided, and every bug you'll avoid each time you change something / refactor something.