Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here's <a href="http://misko.hevery.com/2009/07/14/software-testing-categorization/" rel="noreferrer">an article on test categorization</a> with some arguments</p> <p>I won't mention the benefits of testing as a whole, once we're just comparing unit tests vs. functional tests:</p> <ul> <li><strong>Unit testing helps you reduce the scope where to look when there's an error.</strong> - Let's include classes C, D, E, ..., Z in this scenario. <em>If you have only integration test and it fails, where do you start looking?</em> If you don't have unit tests, <em>you would need to look everywhere inside each of those classes AND the "wiring" between those</em> (which is a narrower scope).If you had unit tests, then you'd just need to check the wiring. In this case, it would also be a bad thing not having some smaller integration tests, like testing A, B, C and D only (so you already know if the "wiring" between those are in fact working).</li> <li><strong>With unit tests, you fail faster</strong>. This is even more true if you TDD. You probably write your tests after you created all of class A and B. When you run your test, the way A and B works is not as fresh in your mind (maybe you wrote them the week before - hopefully you don't start testing only when the product is "finished"). You must then remember what you were thinking when you wrote those. Also, unit test are faster, so you're more likely to run them more frequently (perhaps run them automatically every time you save?)</li> <li><strong>Unit tests provide a better documentation how your class should behave</strong>. If you're a "normal programmer", you probably hate writing documentation. This forces you to write documentation while programming, and <strong>forces the documentation to never be obsolete</strong> (if it is, your tests fail). And <strong>it also helps when you need to change somebody else's code</strong>.</li> </ul> <p>In the <em>ideal</em> world, when a test fails, you won't need more than 2 minutes to know what to look (with no need of debugging). The idea of having tests of all sizes is just a guideline to achieve this goal, rather than spending hours/days/weeks debugging =).</p>
 

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