I changed a junit test class to run with Parameterized to test two different implementations of the same interface. Here it is :
@RunWith(Parameterized.class)
public class Stack_Tests {
private Stack<String> stack;
public Stack_Tests(Stack<String> stack) {
this.stack = stack;
}
@Parameters
public static Collection<Object[]> parameters() {
// The two object to test
return Arrays.asList(new Object[][] { { new LinkedStack<String>() }, { new BoundedLinkedStack<String>(MAX_SIZE) } });
}
@Test
public void test() {
...
}
The results are wrong since I changed to Parameterized. Half of the tests fail (the same for the two objects), all of them worked before.
It works without Parameterized like this :
public class Stack_Tests {
private Stack<String> stack;
@Before
public void setUp() throws Exception {
stack = new LinkedStack<String>();
}
@Test
public void test() {
...
}
The complete test class here