Are there any documented conventions for the order in which method types are placed within JUnit tests? I typically have the following order: @Before
, @Test
, @After
; I have also seen: @Test
, @Before
, @After
.
Example methods:
public class SandBoxTest {
SandBox sand;
@BeforeClass
public void classSetup() { }
@Before
public void given() { }
@Test
public void shouldTestThis() { }
// support method
private boolean doStuff() {
return true;
}
@Test
public void shouldTestThat() { }
@After
public void cleanUp() { }
@AfterClass
public void classCleanUp() { }
}
If there is a 'standard' convention, please provide references.
I think there is no such a coding convention but don't forget about the @Rule annotation.