title: Inheritance (or an alternative) in Parameterized jUnit tests
body: <p>I'd like to do something like this in jUnit:</p>
  
  <pre><code>@Runwith(Parameterized.class)
  public abstract class BaseTest {
  
       protected abstract List&lt;Object[]&gt; extraParams();
       protected abstract ClassUnderTest testObject;
  
       @Parameters
       public Collection&lt;Object[]&gt; data() {
           List&lt;Object&gt; params = ...; // a standard set of tests
           params.addAll(extraParams());
           return params;
       }
  
       @Test
       public doTest() {
           // assert things about testObject
       }
  }
  
  public class ConcreteTest extends BaseTest {
       protected ClassUnderTest = new ConcreteClass(...);
       protected List&lt;Object[]) extraParams() {
           List&lt;Object&gt; extraParams = ...; // tests specific to this concrete type
           return extraParams;
       }
  }
  </code></pre>
  
  <p>So that by extending this class, I run a bunch of standard tests against the object under test, plus some extra ones specified in the concrete class.</p>
  
  <p>However, jUnit requires that the <code>@Parameters</code> method is static. How else can I tidily achieve the aim, of having a set of standard parameters plus extra ones in the concrete classes?</p>
  
  <p>The best I've come up with so far is to have an un-annotated <code>Collection&lt;Object[]&gt; standardParams()</code> in the abstract class, and to require that the subclass contain a method:</p>
  
  <pre><code> @Parameters
   public Collection&lt;Object[]&gt; data() {
       List&lt;Object&gt; params = standardParams();
       params.addAll(...); // extra params
       return params;
   }
  </code></pre>
  
  <p>... but this isn't as tidy as I'd like, as it puts too much responsibility on the writer of the subclass.</p>