Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I don't disagree with Dan (although a better choice may just be not to answer)...but...</p> <p>Unit testing is the process of writing code to test the behavior and functionality of your system.</p> <p>Obviously tests improve the quality of your code, but that's just a superficial benefit of unit testing. The real benefits are to:</p> <ol> <li>Make it easier to change the technical implementation while making sure you don't change the behavior (refactoring). Properly unit tested code can be aggressively refactored/cleaned up with little chance of breaking anything without noticing it.</li> <li>Give developers confidence when adding behavior or making fixes.</li> <li>Document your code</li> <li>Indicate areas of your code that are tightly coupled. It's hard to unit test code that's tightly coupled</li> <li>Provide a means to use your API and look for difficulties early on</li> <li>Indicates methods and classes that aren't very cohesive</li> </ol> <p>You should unit test because its in your interest to deliver a maintainable and quality product to your client.</p> <p>I'd suggest you use it for any system, or part of a system, which models real-world behavior. In other words, it's particularly well suited for enterprise development. I would not use it for throw-away/utility programs. I would not use it for parts of a system that are problematic to test (UI is a common example, but that isn't always the case)</p> <p>The greatest pitfall is that developers test too large a unit, or they consider a method a unit. This is particularly true if you don't understand <a href="https://en.wikipedia.org/wiki/Inversion_of_control" rel="noreferrer">Inversion of Control</a> - in which case your unit tests will always turn into end-to-end integration testing. Unit test should test individual behaviors - and most methods have many behaviors.</p> <p>The greatest misconception is that programmers shouldn't test. Only bad or lazy programmers believe that. Should the guy building your roof not test it? Should the doctor replacing a heart valve not test the new valve? Only a programmer can test that his code does what he intended it to do (QA can test edge cases - how code behaves when it's told to do things the programmer didn't intend, and the client can do acceptance test - does the code do what what the client paid for it to do)</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. 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.
    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