类 CabinSpringRunner
- java.lang.Object
-
- org.junit.runner.Runner
-
- io.esastack.cabin.support.test.junit.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.SortableWhy 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(Class<?> testClass)
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 voidfilter(org.junit.runner.manipulation.Filter filter)org.junit.runner.DescriptiongetDescription()voidrun(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 UnitTestModuleClassLoadervoidsort(org.junit.runner.manipulation.Sorter sorter)
-
-
-
构造器详细资料
-
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
-
-