Unit Testing - What not to test

后端 未结 9 1156
悲哀的现实
悲哀的现实 2020-12-14 07:34

I have gone through a number posts on stackoverflow and numerous articles about Unit Tests. I am just trying to figure out that what I have understood is right.

9条回答
  •  不知归路
    2020-12-14 07:41

    I'm not unit-testing anything, because instead I want the integration and/or system tests to:

    • Cover the code
    • Be automated
    • Be used as, and to be as useful as, unit tests

    For details, see Should one test internal implementation, or only test public behaviour?

    Reversing your question, I suggest that the only code which you should unit test is code:

    a) Which isn't going to be tested at all by integration and/or system testing (and if not, why not?)

    b) Or which should, for whatever reason, be tested before integration/system testing (perhaps because of how which your project's development is partitioned to several developers in parallel)

提交回复
热议问题