Why are most unit tests a waste of time? (translation of the article)

Author: James O Coplien





Translation: Epishev Alexander  





1.1 Our days

In the days of FORTRAN, when function was a function that sometimes deserved functional checks, unit testing was one of the main ingredients. Computers performed computations, while functions and procedures were computational units. In those days, the dominant design approach was to create complex external functionality from smaller pieces, which, in turn, governed even smaller ones, and so on, down to the level of well-understood primitives. Each layer supported the layer above it. Overall, you had a great chance of tracking down how the functionality at the very bottom, the so-called functions and procedureswere associated with requirements expressed in a human-accessible interface. A good designer could be expected to understand the business purpose of a particular function. Relationships in the call tree, at least in well-structured code, were just as understandable. You could mentally simulate the execution of the code during the code review.  





, , , . -, , , , . . , - . , , FORTRAN. - . , , .  





, β€œ ”. - - β€œ ”. - , , . , , - . - . , . , β€œβ€, -. - , , - , , , -, . 





, , , . CRC- ( , ), . . , , , , . , FORTRAN, (, , , , ). . - () , . , . 





1.2

, - - , de rigueur (. " "), , -, , , . , -, , (Richard Jacobs) Sogeti (Sogeti Nederland B.V.):  





☞ -. , , - - . -, . , , , . ( , . . .) , , ... , , , . . , ?





, , , , - . , , , : , , .





, , , , . , , , , , . β€œ ”, , , , , , . . , , , .  





☞ , , . , . . 





(, - , , , , , , , 16- ).





1.3  

, 40% , , , 1- , 60% 2- 80% 3-, 100%. ! , , , divide et impera ( ). , 80% , , 80% . , , . , , . , , , , . - - GOTO. , , - (branch coverage), . 





☞ , , , , , . .





. , , β€œ ” , . , , , , . , . .





. 100% , , , , , . - , . : , 10. ( , ) . -. , , , , 1 1012.





- - . : , , -, .   





☞ , 24/7.





, , - . , Lean-, , Toyota, Scrum, (http://www.computer.org/portal/web/buildyourcareer/Agile Careers/-/blogs/autonomation). - , . - , - . . , , , , , , .





: , , - .. , . : β€œ ”, c J-Tag , - , . , ; , - . - .





, , , , , . . . 





☞ . , . , β€œβ€ .  





1.4 , ,  

, (, , ), , , , - , , . . , , - , .





- , , , , . ; , . , , . , - . , - . , , - . 





☞ -, . ; ; .  





: , . , , , , , - . , , , . , .





☞ , - , ( -, ). , . 





, , . .  





1.5 ( )  

, . , - - X 5, , , , , , X 5. , , , . ; (, , ) , , , .





. - . ( ; . .) β€œβ€ β€œβ€ , . , , . . : β€œ ?” , β€œ1” - , β€œ0” - , :  





 11111111111111111111111111111111  
      
      



, , . - 32, , , . , , , 5. , : , . . 100%, , , . . ( , .) 





, ?





 1011011000110101101000110101101  
      
      



... . , 32. , . , , , - . , , , . ,   . ( , : 





 00000000000000000000000000000000  
      
      



, , , , .)  





☞ , , , - , , . , , , . . - , , , .





. , , . , , . , , , , , . 





, . , , , , . - . , , .





☞ - .  





- . , , , , (TDD). (, β€œthis” / (non-null) , , . , , , . .)





, - - , -. , : , , , . . 1970- 1980- , (tracebility), . , NP- ( ) ( ), , , . , , : β€œ , - ?” , : β€œ ”. , , , . : , , . , . , . , - , .





☞ , - , . , , -. ( , , .) . 





, , , . - ; , , , - . , , . , , , API. , API , . .





☞ , , , β€œ ”, , . β€œβ€ -, , , , β€œβ€, , . , , . 





1.6 -  

: , , , , . , 99,99% , , . , β€œβ€, , (WCA). WCA β€œβ€ , : 100 . , , (FIT rate) 10 - (Failures In a Trillion).





, , , . , : 





, ( ). , , , , , , . , , . ( : 3- - ( , ) - ( ). , , , , , .. .)





, , WCA , - - : . (side effects) , , , , . . , , . 





, , , , . . , , , - . ( , : , - , , . : (Perry and Kaiser), β€œ - ” (β€œAdequate  Testing and Object–oriented Programming”), - 2 (5), 1990 ., . 13). , , . ( β€œ ” - , { , }, ; - , , , - ). (Halting Problem) , .





1.7 -  

, . , ; , , ( β€œ---”) . - . - . . , , , . , , , , , , ! 





, , , . -, . ( , , , , , , , . , .) , -: , (, Agile ). , XP . , Maven , -, . , , - . , : β€œ, Maven , - - , ”.





200, 2000, 10 000 , (-) , . , , 2005 , - ( ) . , - . ; . , , , , , , , , , , , , , . . , - , , - . , . 





-, , , , - , , , .





1.8 !  

, - . - . , - , . , -, - (TDD). , (coupling and coherence), , ( , (Janzen and Saledian), β€œ ?” IEEE Software 25(2), / 2008 ., . 77 - 84.) , , , (coupling) . . , . ( , .)  





, -, JUnit,   (assertions). - , , , , , , - . , . .





- , , , , . , , . , : - β€œ ”, , , . , 5 . : β€œ - , .” . , . 





☞ - (assertions). . , () () ; -. - , : , , -, . 





, -, , . , , , , - , . , , . , Scrum Knowsy, . , , - , . -, , . , . (Rex) , β€œ , , ”.





☞ ; (Lean) . , ( ) - , .





: - () -, - . , , , , , , ... ! , . , .





1.9 β€œ , ”  

, - , , . - , , , , , β€œβ€ . , , , , . -, , - .





. - : , . - . , : - , - . , , .





. β€œ ” , , . , . , .





. , , (debugging). - , . - . -, ad-hoc ( ) , -, . . , , , . 





1.10

Sogeti. , :  





, , . . , ?





, - , , , , - . , . . 2004 , ( ) . : , , . 





, , , , , , . - , . Sogeti : . . , , , , . : β€œ , ”. (fail-fast), , . , - , , ; , , , . , , JUnit .





, , , (Nancy Githinji), IT- ; Microsoft. , ( ), , . , . !





, ( ), , , , - , : β€œ β€œ ” (fail fast) , , … , - , -”. β€œ ” , , IT-. , , , β€œ ”. : β€œ , …”





, : , . . , - Scrum: , , , , ( ) .





: , . , , , . . : , , . , .





jcoplien@gmail.com .





:  





  • , , -.





  • -, , , , , -.





  • , X - X -, : - .





  • , . 





  • - (assertions).





  • , .





  • : , , , , , .





  • , , . .





  • Be humble about the ability of the tests. Tests don't improve quality: developers do.








All Articles