Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It's probably work reading the Wikipedia article on <a href="http://en.wikipedia.org/wiki/Unit_testing" rel="nofollow noreferrer">Unit Testing</a>, as this will answer most of your questions regarding <strong>why</strong>. The <a href="http://junit.org" rel="nofollow noreferrer">JUnit</a> web site has resources for writing a Java unit test, of which the <a href="http://junit.sourceforge.net/doc/cookbook/cookbook.htm" rel="nofollow noreferrer">Junit Cookbook</a> should probably be your first stop.</p> <p>Personally, I write unit tests to test the contract of a method, i.e. the documentation for a particular function. This way you will enter into a cycle of increasing your test coverage and improving documentation. However, you should try to avoid testing:</p> <ul> <li>Other people's code, including the JDK</li> <li>Non-deterministic code, such as java.util.Random</li> </ul> <p>JUnit is not the only unit testing framework available for Java, so you should evaluate other frameworks like <a href="http://testng.org/doc/index.html" rel="nofollow noreferrer">TestNG</a> before diving into it.</p> <p>In addition to "top-level" frameworks, you will also find quite a few projects covering specific areas, such as:</p> <ul> <li><a href="http://htmlunit.sourceforge.net/" rel="nofollow noreferrer">HTMLUnit</a> for Web</li> <li><a href="http://www.cafesip.org/projects/sipunit/" rel="nofollow noreferrer">SIPUnit</a> for SIP</li> <li><a href="https://swingunit.dev.java.net/" rel="nofollow noreferrer">SwingUnit</a> for GUI Code</li> </ul>
 

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