ASP.NET MVC - Unit testing overkill? (TDD)

前端 未结 5 1164
误落风尘
误落风尘 2021-02-04 05:08

So I\'m starting to catch the TDD bug but I\'m wondering if I\'m really doing it right... I seem to be writing A LOT of tests.

The more tests the better

5条回答
  •  情歌与酒
    2021-02-04 05:40

    I'm unit testing only code what i'm unsure about. Sure - you can never know what will back stab you but writing tests for trivial things seems like an overkill for me.

    I'm not a unit-testing/tdd guru - but i think that it's fine if you do NOT write tests just to have them. They must be useful. If you are experienced enough with unit testing - you start to feel when they are going to be valuable and when not.

    You might like this book.

    Edit:
    Actually - i just found a quote about this underneath isolation frameworks chapter. It's about overspecifying tests (one particular test), but i guess the idea remains in more global scope:

    Overspecifying the tests
    If your test has too many expectations, you may create a test that breaks down with even the lightest of code changes, even though the overall functionality still works. Consider this a more technical way of not verifying the right things. Testing interactions is a double-edged sword: test it too much, and you start to lose sight of the big picture—the overall functionality; test it too little, and you’ll miss the important interactions between objects.

提交回复
热议问题