title: JUnit Tests: object not recreated between parameterized tests
body: <p>I'm trying to test implementations of a <code>Collections</code> interface using JUnit4 <code>Parameterized</code> tests. My test class has two tests:</p>
  
  <pre><code>@RunWith(Parameterized.class)
  public class CollectionsTest {
  
      private Collection&lt;String&gt; col;
      private Collection&lt;String&gt; other;
  
      public CollectionsTest(Collection&lt;String&gt; c, Collection&lt;String&gt; other) {
          this.col = c;
          this.other = other;
      }
  
      @Parameterized.Parameters
      public static java.util.Collection&lt;Object[]&gt; tokenStreams() {
          return (java.util.Collection&lt;Object[]&gt;) Arrays.asList(new Object[][] { 
              { new DSLinkedList&lt;String&gt;(), new DSLinkedList&lt;String&gt;() } });
      }
  
      @Test
      public final void isEmpty() {
          assertTrue(col.getClass().getName() + ".isEmpty() should return true when collection contains no elements", col.isEmpty()); 
          col.add("Stringthing");
          assertFalse(col.getClass().getName() + ".isEmpty() should return false when collection contains elements", col.isEmpty());
      }
  
      @Test
      public final void size() {
          assertEquals(col.getClass().getName() + ".size() should be 0 for an empty collection.", 0, col.size());
          col.add("String");
          assertEquals(col.getClass().getName() + ".size() should be 1 for a collection with one element.", 1, col.size());       
      }
  }
  </code></pre>
  
  <p>The second test (<code>size()</code>) always fails: at the time of the first assertion, <code>col</code> contains a single element <code>stringThing</code>, because I inserted an element in the <code>isEmpty()</code> test. </p>
  
  <h3>How do I clean the parameterized objects between tests?</h3>
  
  <p>If I wasn't using a parameterized test, I'd use <code>@Before</code> with a <code>setup()</code> method: should I be using reflection and a setup method here to recreate the <code>col</code> and <code>other</code> objects? (I haven't done this because I don't know which <code>Collection</code> implementation each test is running beforehand: if I have to manually write code using reflection to determine this, what's the point of Parameterized tests?)</p>
  
  <p>My understanding is that the Parameterized tests call the constructor before each test, which should 'reset' my objects cleanly: why is this not the case? </p>