Search code examples
unit-testinglanguage-agnostictddtesting-strategies

What not to test when it comes to Unit Testing?


In which parts of a project writing unit tests is nearly or really impossible? Data access? ftp?

If there is an answer to this question then %100 coverage is a myth, isn't it?


Solution

  • Here I found (via haacked something Michael Feathers says that can be an answer:

    He says,

    A test is not a unit test if:

    • It talks to the database
    • It communicates across the network
    • It touches the file system
    • It can't run at the same time as any of your other unit tests
    • You have to do special things to your environment (such as editing config files) to run it.

    Again in same article he adds:

    Generally, unit tests are supposed to be small, they test a method or the interaction of a couple of methods. When you pull the database, sockets, or file system access into your unit tests, they are not really about those methods any more; they are about the integration of your code with that other software.