title: Java - assertEquals & assertTrue - Test failed with exception [null] in JUnit but passes in test class
body: <p>I have both a standard test class with a main method and a JUnit class which I am using to base my tests while writing a contact directory via Test Driven Development. I need to make use of methods such as assertEquals &amp; assertTrue. As I have never used them before, I wrote a simple test in my standard test class and they return True when expected and throw an exception when expected. </p>
  
  <p>I then moved into my JUnit test class, write the same test that passed in the standard test class and run the JUnit test class. The test fails with the following error:</p>
  
  <pre><code>Test[Method Name] failed with exception [null]
  </code></pre>
  
  <p>The exact code I used is along these lines:</p>
  
  <pre><code>assertEquals("NameImExpectingToFind",obj.searchMethod("nameImSearchingFor").get(0).getName());
  </code></pre>
  
  <p>I've been stuck on this problem for hours. Just makes no sense that it will pass in a standard test class but not in a JUnit test class. </p>
  
  <p>Thanks in advance for any help!</p>
  
  <pre><code>Test class:
      AddressBook main = new AddressBook();
      Entry Will = new Entry("Will", "Blah",
              "Blah, blah, blah", "TF4 3HS", "077774451",
              "01/02/93");
      Entry Ben = new Entry("Ben", "Blah",
              "Blah, blah, blah", "TF4 3HS", "077774451",
              "01/02/93");
      main.addEntry(Will);
      main.addEntry(Ben);
      //assertEquals("Ben",main.cSearchFirst("Ben").get(0).getfName());
      System.out.println("Ben" == main.cSearchFirst("Ben").get(0).getfName());
  </code></pre>
  
  <p>Returns True.</p>
  
  <pre><code>JUnit Test class:
      AddressBook main = new AddressBook();
      Entry Will = new Entry("Will", "Blah",
              "Blah, blah, blah", "TF4 3HS", "077774451",
              "01/02/93");
      Entry Ben = new Entry("Ben", "Blah",
              "Blah, blah, blah", "TF4 3HS", "077774451",
              "01/02/93");
      main.addEntry(Will);
      main.addEntry(Ben);
      assertEquals("Ben",main.cSearchFirst("Ben").get(0).getfName());
      //System.out.println("Ben" == main.cSearchFirst("Ben").get(0).getfName());
  </code></pre>
  
  <p>Returns Test[Method Name] failed with exception [null].</p>