I want to write a test that perform Setup in several ways but expect them to produce the same output. Basically like
@Before
public void setUp1(){
obj.addDataThisWay(data);
}
@Before
public void setUp2(){
obj.addDataThatWay(data);
}
@Test
public void testResult(){
assertEquals(obj.getResult(),1);
}
I want it the test to run twice, one for setUp1()->testResult(), the other one for setUp2()->testResult() Is that possible?
Not to my knowledge. You must either turn this into two separate tests (and extract the assertions to a common, private, non-
@Testmethod if you want to), or you can use parameterized tests.