Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 403
spinodal Avatar asked Sep 20 '08 21:09

spinodal


People also ask

What should you test in a unit test?

Unit tests should validate all of the details, the corner cases and boundary conditions, etc. Component, integration, UI, and functional tests should be used more sparingly, to validate the behavior of the APIs or application as a whole.

What are the errors commonly found during unit testing?

Unit testing considerations What errors are commonly found during Unit Testing? (1) Misunderstood or incorrect arithmetic precedence, (2) Mixed mode operations, (3) Incorrect initialization, (4) Precision inaccuracy, (5) Incorrect symbolic representation of an expression.


1 Answers

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.

like image 111
spinodal Avatar answered Oct 01 '22 22:10

spinodal