Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>First, you are addressing two problems - unit tests (often in the same package as the unit under test) and integration tests. I usually keep my integration tests in a separate package, something like com.example.project.tests. In eclipse, my projects look like:</p> <pre><code>project/ src/ com.example.project/ tsrc/ com.example.project/ com.example.project.tests/ </code></pre> <p>Right-clicking on a package and selecting 'run' runs the tests in the package; doing the same on the source folder runs all the tests. </p> <p>You can acheive a similar effect, although you expressed a disinterest in it, by using the <a href="http://junit.sourceforge.net/javadoc_40/org/junit/runners/Suite.html" rel="nofollow noreferrer">Suite runner</a>. However, this violates DRY - you have to keep copies of the test names up to date in the suite classes. However, you can easily put the same test in multiple suites.</p> <pre><code>@RunWith(Suite.class) @Suite.SuiteClasses( { TestAlpha.class, TestBeta.class }) public class GreekLetterUnitTests { } </code></pre> <p>Of course, I really should be keeping these things automated. A good method for doing that is to use <a href="http://ant.apache.org/manual/Tasks/junit.html" rel="nofollow noreferrer">the Ant task</a>. </p> <pre><code>&lt;target name="tests.unit"&gt; &lt;junit&gt; &lt;batchtest&gt; &lt;fileset dir="tsrc"&gt; &lt;include name="**/Test*.java"/&gt; &lt;exclude name="**/tests/*.java"/&gt; &lt;/fileset&gt; &lt;/batchtest&gt; &lt;/junit&gt; &lt;/target&gt; &lt;target name="tests.integration"&gt; &lt;junit&gt; &lt;batchtest&gt; &lt;fileset dir="tsrc"&gt; &lt;include name="**/tests/Test*.java"/&gt; &lt;/fileset&gt; &lt;/batchtest&gt; &lt;/junit&gt; &lt;/target&gt; </code></pre>
 

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