All,
When writing a test method for method A (which has many internal conditions), should I focus on testing one condition every time? I find it difficult to structure a testing method for method A, which will cover the entire code path in method A.
Can anyone suggest me how to start writing a test method?
My preference is to have one point of failure in the JUnit testing method. This means that I will have many JUnit testing methods for the target class method that I am testing.
testA1(), testA2(), testA3() (A). .
A 8 , 8 , , , .
. , , . , , .
unit test . , . , .
. ,
if (cond1 || cond2) {....}
cond1 cond2. , .
testMyMethodCond1(){...}
testMyMethodCond2(){...}
, . , , " ", , , , , .
, , . -, . . () .
Tests should be simpler, preferably much simpler than the tested thing. Otherwise, the error will most likely be in your test. Therefore, it is much better to have many small simple testing methods that perform small parts of your method than one big clumsy one. (You can use a code coverage tool such as Cobertura to make sure that you cover all the paths in your method.)
Source: https://habr.com/ru/post/1772687/More articles:TDD с MS Test - c#How can I center the tooltip above my control in Silverlight? - tooltipWhy does UIWebView consume so much memory? - memoryDateFormatter that's not picky? - javahow to change c # console project to windows forms application project? - c #Using fancybox on a loaded AJAX page - jqueryКак объявить класс динамически? С# - reflectionEclipse IDE проблема "не win32-приложение" - eclipseJava Creates a new Map.Entry array - javaDoes strcpy'ing eliminate a string in a larger char array memory leak? - c ++All Articles