title: Creating Junit Test Case - java.lang.NoClassDefFoundError
body: <p>I am new to Junit, and I am having issues creating a Junit Test Case. It is causing the error java.lang.NoClassDefFound, as well as a lot of other errors.</p>
  
  <p>I have the following code in a class called Arithmetic:</p>
  
  <pre><code> public class Arithmetic {
    public static int addition(number, number2) { 
          return number + number2;
    }
  </code></pre>
  
  <p>The Junit test code:</p>
  
  <pre><code>import static org.junit.Assert.*;
  import org.junit.Test;
  
  
  public class TestFailure {
  
  @Test
  public void test() throws Exception {
  Arithmetic test = new Arithmetic();
  int output = test.addition(5,8);
  assertEquals(13, output);
  }
  
  }
  </code></pre>
  
  <p>This returns the following error:</p>
  
  <pre><code>java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing
  at java.lang.ClassLoader.defineClass1(Native Method)
  at java.lang.ClassLoader.defineClass(Unknown Source)
  at java.security.SecureClassLoader.defineClass(Unknown Source)
  at java.net.URLClassLoader.defineClass(Unknown Source)
  at java.net.URLClassLoader.access$100(Unknown Source)
  at java.net.URLClassLoader$1.run(Unknown Source)
  at java.net.URLClassLoader$1.run(Unknown Source)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(Unknown Source)
  at java.lang.ClassLoader.loadClass(Unknown Source)
  at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
  at java.lang.ClassLoader.loadClass(Unknown Source)
  at org.junit.internal.builders.JUnit4Builder.runnerForClass                      (JUnit4Builder.java:10)
  at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
  at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
  at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
  at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
  at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.&lt;init&gt;(JUnit4TestReference.java:33)
  at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.&lt;init&gt;(JUnit4TestClassReference.java:25)
  at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:48)
  at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:38)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:444)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
  
   Caused by: java.lang.ClassNotFoundException: org.hamcrest.SelfDescribing
  at java.net.URLClassLoader.findClass(Unknown Source)
  at java.lang.ClassLoader.loadClass(Unknown Source)
  at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
  at java.lang.ClassLoader.loadClass(Unknown Source)
  ... 25 more
  </code></pre>
  
  <p>Note that I have downloaded the junit-4.12.jar and have it installed where my projects are. It is also in my Referenced Libraries as junit-4.12.jar, with a drop down list of many more.</p>