注释类型 TestExecutionListeners

      • inheritListeners

        boolean inheritListeners
        Whether or not TestExecutionListeners from superclasses should be inherited.

        The default value is true, which means that an annotated class will inherit the listeners defined by an annotated superclass. Specifically, the listeners for an annotated class will be appended to the list of listeners defined by an annotated superclass. Thus, subclasses have the option of extending the list of listeners. In the following example, AbstractBaseTest will be configured with DependencyInjectionTestExecutionListener and DirtiesContextTestExecutionListener; whereas, TransactionalTest will be configured with DependencyInjectionTestExecutionListener, DirtiesContextTestExecutionListener, andTransactionalTestExecutionListener, in that order.

         @TestExecutionListeners({
             DependencyInjectionTestExecutionListener.class,
             DirtiesContextTestExecutionListener.class
         })
         public abstract class AbstractBaseTest {
                 // ...
         }
        
         @TestExecutionListeners(TransactionalTestExecutionListener.class)
         public class TransactionalTest extends AbstractBaseTest {
                 // ...
         }

        If inheritListeners is set to false, the listeners for the annotated class will shadow and effectively replace any listeners defined by a superclass.

        默认值:
        true
      • mergeMode

        TestExecutionListeners.MergeMode mergeMode
        The merge mode to use when @TestExecutionListeners is declared on a class that does not inherit listeners from a superclass.

        Can be set to MERGE_WITH_DEFAULTS to have locally declared listeners merged with the default listeners.

        The mode is ignored if listeners are inherited from a superclass.

        Defaults to REPLACE_DEFAULTS for backwards compatibility.

        从以下版本开始:
        4.1
        另请参阅:
        TestExecutionListeners.MergeMode
        默认值:
        org.springframework.test.context.TestExecutionListeners.MergeMode.REPLACE_DEFAULTS