Por que a maioria dos testes de unidade é uma perda de tempo? (tradução do artigo)

Autor: James O Coplien





Tradução: Epishev Alexander  





1.1 Nossos dias

Na Ă©poca do FORTRAN, quando a função era uma função que Ă s vezes merecia verificaçÔes funcionais, o teste de unidade era um dos ingredientes principais. Os computadores realizavam cĂĄlculos, enquanto as funçÔes e procedimentos eram unidades computacionais. Naquela Ă©poca, a abordagem de design dominante era criar funcionalidades externas complexas a partir de blocos menores, que, por sua vez, governavam os menores ainda, e assim por diante, atĂ© o nĂ­vel de primitivos bem compreendidos. Cada camada apoiou a camada acima dela. No geral, vocĂȘ teve uma grande chance de rastrear como a funcionalidade na parte inferior, as chamadas funçÔes e procedimentosforam associados a requisitos expressos em uma interface acessĂ­vel por humanos. Pode-se esperar que um bom designer compreenda o propĂłsito comercial de uma função especĂ­fica. Os relacionamentos na ĂĄrvore de chamadas, pelo menos em cĂłdigo bem estruturado, eram igualmente fĂĄceis de entender. VocĂȘ pode simular mentalmente a execução do cĂłdigo durante a revisĂŁo do cĂłdigo.  





, , , . -, , , , . . , - . , , 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).





  • , .





  • : , , , , , .





  • , , . .





  • Seja humilde quanto Ă  capacidade dos testes. Os testes nĂŁo melhoram a qualidade: os desenvolvedores sim.








All Articles