SpringJUnit4ClassRunner和SpringRunner有什么区别


Answers:



30

@RunWith(SpringRunner.class)告诉JUnit使用Spring的测试支持运行。SpringRunner是的新名称SpringJUnit4ClassRunner,在眼睛上稍微容易一点。

SpringRunner 仅在春季测试4.3中可用。

SpringRunner类扩展SpringJUnit4ClassRunner

源代码SpringRunnerIS

package org.springframework.test.context.junit4;

import org.junit.runners.model.InitializationError;

public final class SpringRunner extends SpringJUnit4ClassRunner {

    public SpringRunner(Class<?> clazz) throws InitializationError {
        super(clazz);
    }

}

7
这似乎与早期答案非常相似。
StvnBrkdll

7
这增加了更多信息,以了解SpringRunner&之间的详细关系SpringJUnit4ClassRunner
艾迪(Eddy)
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.