Level of detail for your unit tests

I wanted to start a discussion of the details that you cover in your unit tests.

Do you test the main functions, which consist of several methods that perform the same task at the same time with one test? or maybe you even check automatic properties?

Since, for example, I see little value when writing a test that will only check this:

   public Email
   {
      set
      {
         if(Regex.Match(/*....*/))
             email = value;
      }
      get
      {
        return email;
      }
   }

How it is really clear, and it is just a waste of time. Usually, when I perform unit tests, I test the whole task - for example, in this example - the entire registration procedure.

, " , ", , , .

?

+3
7

, , , . , , , STILL . , . , , .

, , . get/set. ? . , . , . , , , .

, , - . , . . .

, -, , . , regex , . . , , , . , - . , , , . , , .

. , , ? , . Email.set . , . , . , , , , .

, . , . , , . Email.is_email_address, . . , WRONG, EMAIL HATES LIVING!

, , . , , . Email - , unit test.

+12

. . , . , , .

, , , . , , . , , . . unit test unit test, , , .

, , . , . , " ". , - , , , . , Murphy , , , , .

+6

, , .

, , , - -, , ?

, Email , email . . ? ( , ), ?

, , unit test, IMO.

, , , .

+2

, . , , , .

, 100% ( ) ( IDE , - ). , , , , , .

( "DI" ) ( "IoC" ) , , ( ), . , .

.

+1

, , , . , . , , , , .

cletus, . , , , - .

+1

, , , . if, . , , .

if(some simple condition), , , . , , . ! , && ||, . , , ( ), , .

, AAA (, , ) API, ! , , (), API .

- , , . , , , , , .

+1

, . .

  • , . , , , . (.. ).
  • , , . forward/get, , .
  • , , . , , , , .

, , , , , .

+1

All Articles