blob: a6511eca386321f32a63d1aea3c022b19cdacb0d [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Mirrored from wiki.objectweb.org/eclipse-webtools/Wiki.jsp?page=UnitTestGuidelines by HTTrack Website Copier/3.x [XR&CO'2003], Fri, 23 Apr 2004 19:12:15 GMT --><head>
<meta http-equiv="content-type" content="text/html;charset=ISO-8859-1">
<title>Eclipse Web Tools Platform Project Wiki: Unit Test Guidelines</title>
<link rel="stylesheet" href="templates/eclipse/eclipse.css">
</head>
<body>
<table border="0" cellspacing="5" cellpadding="2" width="100%" >
<tr>
<td align="left" width="60%"><font class="indextop">eclipse web tools<br>platform project</font><br><font class="indexsub">Unit Test Guidelines</font></td>
<td width="40%"><img src="images/Idea.jpg" hspace="50" align="center" width="120" height="86"></td>
</tr>
</table>
<table border="0" cellspacing="5" cellpadding="2" width="100%" >
<tr>
<td valign="top">
<HR />
This project proposal is in the
<a href="/projects/dev_process/">
Proposal Phase</a> and is posted here to solicit additional project
participation and ways the project can be leveraged from the Eclipse
membership-at-large. You are invited to comment on and/or
<a href="Wikiaed0.html">join the project</a>. Please send all feedback to the
<a href="http://www.eclipse.org/newsportal/thread.php?group=eclipse.webtools">eclipse.webtools</a>
newsgroup or the <a href="https://dev.eclipse.org/mailman/listinfo/wtp-proposal">
wtp-proposal</a> mailing list.
<HR />
<P>
<I>This document was inspired by the <A CLASS="external" HREF="http://dev.eclipse.org/viewcvs/index.cgi/~checkout~/cdt-home/developer/unittests.html?">CDT Unit test document</A><img class="outlink" src="images/out.png" alt="" width="6" height="6" /></I>
<P>
<H3>1. Introduction</H3>
Is has been well proven that the time taken to write and run unit tests is recouped many times by reducing the time required to manually test, find and fix bugs. The WTP Team has adopted a policy of writing JUnit tests for WTP code in the following priority:
<P>
<UL>
<LI>Critical and/or complex code should always have a unit test associated with it
</LI>
<LI>Code that is found to contain an error must have a unit test created and successfully run as a requirement of closing the PR associated with the error.
</LI>
<LI>All other code as time permits and common sense dictates
</LI>
</UL>
<P>
These tests will be integrated into our build process. Builds will not be marked as successful unless all unit tests, especially regression tests, run successfully. See the current <A CLASS="external" HREF="http://download.eclipse.org/downloads/documentation/2.0/html/plugins/org.eclipse.jdt.doc.user/tasks/tasks-207.htm">Eclipse JUnit Help Pages</A><img class="outlink" src="images/out.png" alt="" width="6" height="6" /> for detailed instructions on creating and running JUnit tests within Eclipse.
<P>
In addition, the WTP Team is exploring the use of the following tools derived from JUnit. The following section on package naming conventions will hold true for tests using JDepend and/or JFunc and any other testing tools extending JUnit.
<P>
<UL>
<LI><A CLASS="external" HREF="http://www.clarkware.com/software/JDepend.html">JDepend</A><img class="outlink" src="images/out.png" alt="" width="6" height="6" /> for generating metrics from the WTP code.
</LI>
<LI><A CLASS="external" HREF="http://jfunc.sourceforge.net/">JFunc</A><img class="outlink" src="images/out.png" alt="" width="6" height="6" /> for creating functional tests for the WTP code.
</LI>
</UL>
<P>
<H3>2. WTP JUnit Test Package Naming Conventions</H3>
<P>
<I>In order to integrate the unit tests with our build process we have proposed the following structure and format be followed by all developers writing unit tests for WTP code. Suggestions for improvements are always welcome.</I>
<P>
Create a JUnit project for each project that you are testing. The JUnit project name should be identical to the project being tested, with the additional postfix of &quot;.tests&quot;.
<P>
<I>For example:</I>
<P>
Say the classes that you are testing are contained in project named org.eclipse.wtp.tools.foobar
<P>
You would create a Java Project called org.eclipse.wtp.tools.foobar.tests
<P>
In the project &quot;org.eclipse.wtp.tools.foobar.tests&quot; you would create tests in package structures that mirror the packages of the classes that they are designed to test.
<P>
Say that your project contained packages called:
<P>
<UL>
<LI><I>org.eclipse.wtp.tools.foobar.internal</I>
</LI>
<LI><I>org.eclipse.wtp.tools.foobar.debug</I>
</LI>
</UL>
<P>
You would create corresponding packages within the test project org.eclipse.wtp.tools.foobar.tests called:
<P>
<UL>
<LI><I>org.eclipse.wtp.tools.foobar.internal.tests</I>
</LI>
<LI><I>org.eclipse.wtp.tools.foobar.debug.tests</I>
</LI>
</UL>
<P>
Individual tests and test suites would reside in each of the corresponding packages. Tests to test the code in <I>org.eclipse.wtp.tools.foobar.internal</I> would be found in <I>org.eclipse.wtp.tools.foobar.internal.tests</I>. Likewise, tests to test the code in <I>org.eclipse.wtp.tools.foobar.debug</I> would be found in <I>org.eclipse.wtp.tools.foobar.debug.tests</I>'.
The higher level main test class &quot;AllTests.java&quot; would reside in the test project <I>org.eclipse.wtp.tools.foobar.common.tests</I>
<P>
<P>
<H4>3. References</H4>
<P>
<A CLASS="external" HREF="http://dev.eclipse.org/viewcvs/index.cgi/~checkout~/jdt-ui-home/plugins/org.eclipse.jdt.junit/index.html">JUnit has a plug-in</A><img class="outlink" src="images/out.png" alt="" width="6" height="6" /> that is bundled with Eclipse 2.0. It includes the following plug-ins:
<UL>
<LI>org.junit
</LI>
<LI>org.eclipse.jdt.junit
</LI>
</UL>
The main <A CLASS="external" HREF="http://www.junit.org/">JUnit</A><img class="outlink" src="images/out.png" alt="" width="6" height="6" /> website has a wealth of information and additional QA tools.
<UL>
<LI>The <A CLASS="external" HREF="http://www.clarkware.com/software/JDepend.html">JDepend</A><img class="outlink" src="images/out.png" alt="" width="6" height="6" /> homepage.
</LI>
<LI>The <A CLASS="external" HREF="http://jfunc.sourceforge.net/">JFunc</A><img class="outlink" src="images/out.png" alt="" width="6" height="6" /> homepage.
</LI>
</UL>
</td>
</tr>
</table>
</body>
<!-- Mirrored from wiki.objectweb.org/eclipse-webtools/Wiki.jsp?page=UnitTestGuidelines by HTTrack Website Copier/3.x [XR&CO'2003], Fri, 23 Apr 2004 19:12:15 GMT -->
<meta http-equiv="content-type" content="text/html;charset=ISO-8859-1">
</html>