Class ParameterizedTestSpiInstantiator


  • class ParameterizedTestSpiInstantiator
    extends java.lang.Object
    Since:
    5.12
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static <T> java.lang.reflect.Constructor<?> findBestConstructor​(java.lang.Class<T> spiInterface, java.lang.Class<? extends T> implementationClass)
      Find the "best" constructor for the supplied implementation class.
      private static <T> java.lang.reflect.Constructor<? extends T> findConstructor​(java.lang.Class<T> spiInterface, java.lang.Class<? extends T> implementationClass)  
      (package private) static <T> T instantiate​(java.lang.Class<T> spiInterface, java.lang.Class<? extends T> implementationClass, org.junit.jupiter.api.extension.ExtensionContext extensionContext)  
      • Methods inherited from class java.lang.Object

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

      • ParameterizedTestSpiInstantiator

        ParameterizedTestSpiInstantiator()
    • Method Detail

      • instantiate

        static <T> T instantiate​(java.lang.Class<T> spiInterface,
                                 java.lang.Class<? extends T> implementationClass,
                                 org.junit.jupiter.api.extension.ExtensionContext extensionContext)
      • findConstructor

        private static <T> java.lang.reflect.Constructor<? extends T> findConstructor​(java.lang.Class<T> spiInterface,
                                                                                      java.lang.Class<? extends T> implementationClass)
      • findBestConstructor

        private static <T> java.lang.reflect.Constructor<?> findBestConstructor​(java.lang.Class<T> spiInterface,
                                                                                java.lang.Class<? extends T> implementationClass)
        Find the "best" constructor for the supplied implementation class.

        For backward compatibility, it first checks for a single constructor and returns that. If there are multiple constructors, it checks for a default constructor which takes precedence over any other constructors. Otherwise, this method throws an exception stating that it failed to find a suitable constructor.