Interface ExtensionRegistrar

  • All Known Implementing Classes:
    MutableExtensionRegistry

    @API(status=INTERNAL,
         since="5.5")
    public interface ExtensionRegistrar
    An ExtensionRegistrar is used to register extensions.
    Since:
    5.5
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void registerExtension​(java.lang.Class<? extends org.junit.jupiter.api.extension.Extension> extensionType)
      Instantiate an extension of the given type using its default constructor and register it in the registry.
      void registerExtension​(org.junit.jupiter.api.extension.Extension extension, java.lang.Object source)
      Register the supplied Extension, without checking if an extension of that type has already been registered.
      void registerSyntheticExtension​(org.junit.jupiter.api.extension.Extension extension, java.lang.Object source)
      Register the supplied Extension as a synthetic extension, without checking if an extension of that type has already been registered.
    • Method Detail

      • registerExtension

        void registerExtension​(java.lang.Class<? extends org.junit.jupiter.api.extension.Extension> extensionType)
        Instantiate an extension of the given type using its default constructor and register it in the registry.

        A new Extension should not be registered if an extension of the given type already exists in the registry or a parent registry.

        Parameters:
        extensionType - the type of extension to register
        Since:
        5.8
      • registerExtension

        void registerExtension​(org.junit.jupiter.api.extension.Extension extension,
                               java.lang.Object source)
        Register the supplied Extension, without checking if an extension of that type has already been registered.

        Semantics for Source

        If an extension is registered declaratively via @ExtendWith, the source and the extension should be the same object. However, if an extension is registered programmatically via @RegisterExtension, the source object should be the Field that is annotated with @RegisterExtension. Similarly, if an extension is registered programmatically as a lambda expression or method reference, the source object should be the underlying Method that implements the extension API.

        Parameters:
        extension - the extension to register; never null
        source - the source of the extension; never null
      • registerSyntheticExtension

        void registerSyntheticExtension​(org.junit.jupiter.api.extension.Extension extension,
                                        java.lang.Object source)
        Register the supplied Extension as a synthetic extension, without checking if an extension of that type has already been registered.
        Parameters:
        extension - the extension to register; never null
        source - the source of the extension; never null
        Since:
        5.8
        See Also:
        registerExtension(Extension, Object)