Class AbstractAllOrEachExtension

java.lang.Object
com.linecorp.armeria.testing.junit5.common.AbstractAllOrEachExtension
All Implemented Interfaces:
org.junit.jupiter.api.extension.AfterAllCallback, org.junit.jupiter.api.extension.AfterEachCallback, org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.BeforeEachCallback, org.junit.jupiter.api.extension.Extension
Direct Known Subclasses:
EventLoopExtension, EventLoopGroupExtension, SelfSignedCertificateExtension, ServerExtension

public abstract class AbstractAllOrEachExtension extends Object implements org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.AfterAllCallback, org.junit.jupiter.api.extension.BeforeEachCallback, org.junit.jupiter.api.extension.AfterEachCallback
A base class for JUnit5 extensions that allows implementations to control whether the callbacks are run around the entire class, like BeforeAll or AfterAll, or around each test method, like BeforeEach or AfterEach. By default, the extension will run around the entire class - implementations that want to run around each test method instead should override runForEachTest().
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract void
    after(org.junit.jupiter.api.extension.ExtensionContext context)
    A method that should be run at the end of a test lifecycle.
    final void
    afterAll(org.junit.jupiter.api.extension.ExtensionContext context)
     
    void
    afterEach(org.junit.jupiter.api.extension.ExtensionContext context)
     
    protected abstract void
    before(org.junit.jupiter.api.extension.ExtensionContext context)
    A method that should be run at the beginning of a test lifecycle.
    final void
    beforeAll(org.junit.jupiter.api.extension.ExtensionContext context)
     
    void
    beforeEach(org.junit.jupiter.api.extension.ExtensionContext context)
     
    protected boolean
    Returns whether this extension should run around each test method instead of the entire test class.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AbstractAllOrEachExtension

      public AbstractAllOrEachExtension()
  • Method Details

    • before

      protected abstract void before(org.junit.jupiter.api.extension.ExtensionContext context) throws Exception
      A method that should be run at the beginning of a test lifecycle. If runForEachTest() returns false, this is run once before all tests, otherwise it is run before each test method.
      Throws:
      Exception
    • after

      protected abstract void after(org.junit.jupiter.api.extension.ExtensionContext context) throws Exception
      A method that should be run at the end of a test lifecycle. If runForEachTest() returns false, this is run once after all tests, otherwise it is run after each test method.
      Throws:
      Exception
    • beforeAll

      public final void beforeAll(org.junit.jupiter.api.extension.ExtensionContext context) throws Exception
      Specified by:
      beforeAll in interface org.junit.jupiter.api.extension.BeforeAllCallback
      Throws:
      Exception
    • afterAll

      public final void afterAll(org.junit.jupiter.api.extension.ExtensionContext context) throws Exception
      Specified by:
      afterAll in interface org.junit.jupiter.api.extension.AfterAllCallback
      Throws:
      Exception
    • beforeEach

      public void beforeEach(org.junit.jupiter.api.extension.ExtensionContext context) throws Exception
      Specified by:
      beforeEach in interface org.junit.jupiter.api.extension.BeforeEachCallback
      Throws:
      Exception
    • afterEach

      public void afterEach(org.junit.jupiter.api.extension.ExtensionContext context) throws Exception
      Specified by:
      afterEach in interface org.junit.jupiter.api.extension.AfterEachCallback
      Throws:
      Exception
    • runForEachTest

      protected boolean runForEachTest()
      Returns whether this extension should run around each test method instead of the entire test class. Implementations should override this method to return true to run around each test method.