类 CabinSpringRunner

  • 所有已实现的接口:
    org.junit.runner.Describable, org.junit.runner.manipulation.Filterable, org.junit.runner.manipulation.Sortable

    public class CabinSpringRunner
    extends org.junit.runner.Runner
    implements org.junit.runner.manipulation.Filterable, org.junit.runner.manipulation.Sortable
    Why do we load the real Runner with TestBizClassLoader? 1. The test class must be loaded by TestBizClassLoader; 2. Spring/springboot load the beans with TCCL class loader, in order to assign the bean to ref field(which is loaded by TestBizClassLoader) of test class, TCCL must be TestBizClassLoader; 3. Springboot scan and load the SPI implementations with TCCL, if the Spring classes are loaded by AppClassloader, the SPI implementations could not be assigned to the SPI refs. So, the best way is to load both Spring classes and test class with TestBizClassLoader.
    • 构造器详细资料

      • CabinSpringRunner

        public CabinSpringRunner​(Class<?> testClass)
    • 方法详细资料

      • getDescription

        public org.junit.runner.Description getDescription()
        指定者:
        getDescription 在接口中 org.junit.runner.Describable
        指定者:
        getDescription 在类中 org.junit.runner.Runner
      • run

        public void run​(org.junit.runner.notification.RunNotifier notifier)
        In the run method, TCCL would be used to load Spring SPI classes, so it should be set to UnitTestModuleClassLoader
        指定者:
        run 在类中 org.junit.runner.Runner
      • filter

        public void filter​(org.junit.runner.manipulation.Filter filter)
                    throws org.junit.runner.manipulation.NoTestsRemainException
        指定者:
        filter 在接口中 org.junit.runner.manipulation.Filterable
        抛出:
        org.junit.runner.manipulation.NoTestsRemainException
      • sort

        public void sort​(org.junit.runner.manipulation.Sorter sorter)
        指定者:
        sort 在接口中 org.junit.runner.manipulation.Sortable