I have a test with 15-20 different test cases, I want to run the same test twice with two different parameters that must be passed to the method of the BeforeClass method, for example:
public class TestOne { private static ClassToTest classToTest; @BeforeClass public static void setUp() throws Exception { classToTest = new ClassToTest("Argument1", "Argument2"); } @Test public void testOne() { ........roughly 15 - 20 tests here } public class TestTwo { private static ClassToTest classToTest; @BeforeClass public static void setUp() throws Exception { classToTest = new ClassToTest("Argument3", "Argument4"); } @Test public void testOne() { ........roughly 15 - 20 tests here, same as in TestOne }
As you can see, the only difference between the two tests is the installation method, which passes different values ββto the ClassToTest constructor. I do not want to replicate testing methods in both classes, but would prefer either inheritance or some other reasonable way to achieve this in one class.
source share