Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Goood Morning,</p> <p>the trick is (like Dave Newton already said) to set the Classpath right. In a batch file it would look like this:</p> <pre><code>set CLASSPATH=D:\_zip\lib\junit.jar;D:\containing_folder java org.junit.runner.JUnitCore package_name.ClassTest </code></pre> <p>The important thing here is to have the following things in your Classpath:</p> <ul> <li>JUnit class files </li> <li>Your class files, including your JUnit test classes</li> <li>Libraries your class files depend on</li> </ul> <p>This means you have to set the <strong>containing folder of your class files</strong> (in my example it's <strong>D:\_zip</strong>) in the classpath. So you can set the full classname (including packages) as an argument for the JUnitCore.</p> <p><strong>A good FAQ is here: <a href="http://junit.sourceforge.net/doc/faq/faq.htm#running_1" rel="nofollow">http://junit.sourceforge.net/doc/faq/faq.htm#running_1</a></strong></p> <hr> <p><em><strong>Update:</em></strong> I'm not sure how the bash script und MacOS works, but if you have your classes packed in a JAR file, it would be enough, to set the CLASSPATH inside the JAR files' manifest:</p> <pre><code>Manifest-Version: 1.0 Created-By: 1.6.0_26-b03 (Sun Microsystems Inc.) Built-By: Gruber ^^ Implementation-Vendor: Company Implementation-Title: Title Implementation-Version: 1.0 Main-Class: package_name.ClassTest Class-Path: /Users/myname/Desktop/Programming/Java/junit4.10/junit-4.10.jar </code></pre> <p>The <em>Main-Class</em> is not really important for the JUnit tests, but i left it here. The manifest file is set inside the JAR:</p> <pre><code>package_name.jar/META-INF/MANIFEST.MF </code></pre> <p>You can set it manually or Eclipse will set it for you (export to jar, etc), if you use it ^^.</p> <p>With this Manifest set, the script should look like this (called from the same directory as the jar file):</p> <pre><code>set CLASSPATH=package_name.jar java org.junit.runner.JUnitCore package_name.ClassTest </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