Before runs before the suite, BeforeEach runs before each test (if memory serves). The big feature was dynamic tests, we managed to refactor most of our tests to a single data file and a factory which generates all the tests.
In 4, @BeforeClass runs once. @Before requires you to annotate a specific test. It sounds like @BeforeEach would allow you to do a single annotation that would run again and again, as if you had duplicated that annotation for each of your tests.
That's exactly what @Before does in Junit4. You annotate a method with @Before, and it's called before each test.
public class MainTest {
@Before
public void setUp() {
System.out.println("Test executed");
}
@Test
public void testOne() {}
@Test
public void testTwo() {}
@Test
public void testThree() {}
}
5
u/Trout_Tickler Sep 10 '17
There was one but the features I switched for were @BeforeEach and dynamic tests.