Skip to content

Instantly share code, notes, and snippets.

@wkorando
Last active February 20, 2019 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wkorando/a2f10e6acde3b50c65fb94e5a816fcf6 to your computer and use it in GitHub Desktop.
Save wkorando/a2f10e6acde3b50c65fb94e5a816fcf6 to your computer and use it in GitHub Desktop.
public class TestExtensionOrdering {
@RegisterExtension
@Order(3)
static ExampleJUnit5Extension extensionA = new ExampleJUnit5Extension("A");
@RegisterExtension
@Order(2)
static ExampleJUnit5Extension extensionB = new ExampleJUnit5Extension("B");
@RegisterExtension
@Order(1)
static ExampleJUnit5Extension extensionC = new ExampleJUnit5Extension("C");
@Test
public void testCaseA() {
// Do nothing
}
@Test
public void testCaseB() {
// Do nothing
}
public static class ExampleJUnit5Extension
implements BeforeAllCallback, AfterAllCallback, BeforeEachCallback, AfterEachCallback {
private String value;
public ExampleJUnit5Extension(String value) {
this.value = value;
}
@Override
public void beforeAll(ExtensionContext context) throws Exception {
System.out.println("Executing beforeAll with value:" + value);
}
@Override
public void afterAll(ExtensionContext context) throws Exception {
System.out.println("Executing afterAll with value:" + value);
}
@Override
public void afterEach(ExtensionContext context) throws Exception {
System.out.println("Executing afterEach with value:" + value);
}
@Override
public void beforeEach(ExtensionContext context) throws Exception {
System.out.println("Executing beforeEach with value:" + value);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment