Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Modify the subject <a href="http://xunitpatterns.com/SUT.html" rel="noreferrer">under test (SUT)</a>. If something is hard to unit test, then the design might be awkward.</p> <p>Faking method calls within the class under test leads to over specified tests. The result are very brittle tests: As soon as you modify or refactor the class, then it is very likely that you also need modify the unit tests. This leads too high maintenance costs of unit testing.</p> <p>To avoid over specified tests, concentrate on public methods. If this method calls other methods within the class, do not test these calls. On the other hand: Method calls on other <a href="http://xunitpatterns.com/DOC.html" rel="noreferrer">dependend on component (DOCs)</a> should be tested.</p> <p>If you stick to that and have the feeling that you miss some important thing in your tests, then it might be a sign for a class or a method which is doing too much. In case of a class: Look for violations of the <a href="http://en.wikipedia.org/wiki/Single_responsibility_principle" rel="noreferrer">Single Responsibility Principle (SRP)</a>. Extract classes out of it and test them separately. In case of a method: Split it up the method in several public methods and test each of them separately. If this is still too awkward, you definitely have a class which violates the SRP.</p> <p>In your specific case you can do the following: Extract the methods <code>ExportExcelDocToDataSet</code> and <code>GetDataTableFromExcelSheet</code> into two different classes (maybe call them <code>ExcelToDataSetExporter</code> and <code>ExcelSheetToDataTableExporter</code>). The original class which contained both methods should reference both classes and call those methods, which you previously extracted. Now you are able to test all three classes in isolation. Apply the <a href="http://martinfowler.com/refactoring/catalog/extractClass.html" rel="noreferrer">Extract Class refactoring</a> (<a href="http://rads.stackoverflow.com/amzn/click/0201485672" rel="noreferrer">book</a>) to achieve the modification of your original class.</p> <p>Also note that retrofitting tests are always a bit cumbersome to write and maintain. The reason is that the SUTs, which are written without unit tests, tend to have an awkward design and thus are harder to test. This means that the problems with unit tests must be solved by modifying the SUTs and cannot be solved by pimping up the unit tests.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload