Last active
February 20, 2019 21:10
-
-
Save wkorando/a2f10e6acde3b50c65fb94e5a816fcf6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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