title: Junit 2.0 : Different results for same test
body: <p>I'm having different results for the same test in JUnit. The first test seems to be OK and to verify all the assertions, I believe that the class works fine.  Then I rerun the test and I get an assertion failure. I realized that the problem was that I didn't clear the "data" after the test, and I tried to fix it doing exactly that, but I'm still having those assertion failures.</p>
  
  <p>Any ideas? </p>
  
  <p>Unit Test: </p>
  
  <pre><code>import static org.junit.Assert.*;
  
  import org.junit.After;
  import org.junit.Before;
  import org.junit.Test;
  
  /**
   * The test class TestHistorial.
   *
   * @author (your name)
   * @version (a version number or a date)
   */
  public class TestHistorial extends junit.framework.TestCase {
      Historial hist;
  
      /**
       * Default constructor for test class TestHistorial
       */
      public TestHistorial() {
      }
  
      /**
       * Sets up the test fixture.
       * &lt;p/&gt;
       * Called before every test case method.
       */
      @Before
      public void setUp() {
          hist = new BaseDatos();
      }
  
      /**
       * Tears down the test fixture.
       * &lt;p/&gt;
       * Called after every test case method.
       */
      @After
      public void tearDown() {
          hist.eliminarTodosLosRegistros();
      }
  
      /**
       * Prueba
       */
  
      public void testHistorial() {
  
          for (int i = 0; i &lt; 20; i++) {
              Registro reg = new RegistroTemperatura(273 + i, 1900 + i, i + 1, i + 1, i);
              try {
                  hist.agregarRegistro(reg);
              } catch (Exception e) {
                  assertEquals(false, true);
              } // No debería llegar aquí.
              String str = "Reg_" + i;
              Registro tReg = hist.getRegistroPorId(str);
              try {
                  Temperatura t = new Temperatura(273 + i);
                  assertEquals(true, t.equals(((RegistroTemperatura) tReg).getTemperatura()));
              } catch (Exception e1) {
                  assertEquals(false, true);
              } // No debería llegar aquí.
              try {
                  Fecha f = new Fecha(1900 + i, i + 1, i + 1, i);
                  assertEquals(true, f.equals(tReg.getFecha()));
              } catch (Exception e2) {
                  assertEquals(false, true);
              } // No debería llegar aquí.
          }
          assertEquals(20, hist.getNumeroDeRegistros());
          assertEquals(true, hist.getRegistroMasViejo().equals(new RegistroTemperatura(273, 1900, 1, 1, 0)));
  
      }
  }
  </code></pre>
  
  <p>The output of the test after first testing is: </p>
  
  <p>$> expected: false but was: true</p>
  
  <p>The real question is, is the <code>tearDown()</code> method being executed after `testHistorial()``? If 
  it isn't, how should I do it? </p>