Junit RunWith
2021-07-04 17:21:55 1 举报
Junit RunWith流程
作者其他创作
大纲/内容
runnerClass.getConstructor(Class.class).newInstance(testClass);
ParentRunner构造方法ParentRunner(Class<?> testClass)
runnerForClass
MemoizingRequest
先调用Runner的safeRunnerForClass(fTestClass)
getRunner()
至此runner已成功找到并且通过构造函数加载,接下来就会进入JunitCore的run(Runner runner) 方法
AllDefaultPossibilitiesBuilder
createTestClass(Class<?> testClass)
this.methodsForAnnotations = makeDeeplyUnmodifiable(methodsForAnnotations); this.fieldsForAnnotations = makeDeeplyUnmodifiable(fieldsForAnnotations);
buildRunner
BlockJUnit4ClassRunner构造方法
getAnnotation(RunWith.class)
调用AllDefaultPossibilitiesBuilder的runnerForClass,然后再循环遍历每个Builder的safeRunnerForClass()
某个指定的Builder,比如AnnotatedBuilder的safeRunnerForClass(实际上都是调用RunnerBuilder的safeRunnerForClass)
CustomAllDefaultPossibilitiesBuilder
createRunner()
new TestClass(testClass);
触发public Theories(Class<?> klass)构造器方法构建Theories
RunnerBuilder
0 条评论
下一页