Class GreenMailExtension

All Implemented Interfaces:
GreenMailOperations, AfterAllCallback, AfterEachCallback, BeforeAllCallback, BeforeEachCallback, Extension

public class GreenMailExtension extends GreenMailProxy implements BeforeAllCallback, AfterAllCallback, BeforeEachCallback, AfterEachCallback
To use this extension you need to use @RegisterExtension Junit5 mechanism and made variable static.
But if you want to remove static keyword annotate test class with @TestInstance(TestInstance.Lifecycle.PER_CLASS).

By default you get a new GreenMail instance per method which works with BeforeEach. You can use withPerMethodLifecycle(boolean) to control this behavior - eg to speed up at the cost of isolation using only BeforeAll

    @RegisterExtension
    GreenMailExtension greenMail = new GreenMailExtension(ServerSetupTest.SMTP_IMAP)
             .withPerMethodLifecycle(false);

    @BeforeAll
    public void setup() { ... }
 
See Also: