Polish Mockito 2.0 support

pull/7881/merge
Phillip Webb 8 years ago
parent abb8e3663a
commit 0fca9aaccb

@ -91,7 +91,7 @@ class MockitoAopProxyTargetInterceptor implements MethodInterceptor {
private final MockingProgress progress; private final MockingProgress progress;
public Verification(Object target) { Verification(Object target) {
this.progress = MockitoApi.get().mockingProgress(target); this.progress = MockitoApi.get().mockingProgress(target);
} }

@ -164,9 +164,9 @@ abstract class MockitoApi {
private final Method getMatcherMethod; private final Method getMatcherMethod;
private Constructor<MockAwareVerificationMode> mockAwareVerificationModeConstructor; private final Constructor<MockAwareVerificationMode> mockAwareVerificationModeConstructor;
public Mockito2Api() { Mockito2Api() {
this.getMockSettingsMethod = ReflectionUtils.findMethod(MockUtil.class, this.getMockSettingsMethod = ReflectionUtils.findMethod(MockUtil.class,
"getMockSettings", Object.class); "getMockSettings", Object.class);
this.mockingProgressMethod = ReflectionUtils this.mockingProgressMethod = ReflectionUtils

@ -20,6 +20,7 @@ import org.junit.Test;
import org.junit.runner.JUnitCore; import org.junit.runner.JUnitCore;
import org.junit.runner.Result; import org.junit.runner.Result;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runner.notification.Failure;
import org.springframework.boot.junit.runner.classpath.ClassPathOverrides; import org.springframework.boot.junit.runner.classpath.ClassPathOverrides;
import org.springframework.boot.junit.runner.classpath.ModifiedClassPathRunner; import org.springframework.boot.junit.runner.classpath.ModifiedClassPathRunner;
@ -47,6 +48,9 @@ public class Mockito21Tests {
private void runTests(Class<?> testClass) { private void runTests(Class<?> testClass) {
Result result = new JUnitCore().run(testClass); Result result = new JUnitCore().run(testClass);
for (Failure failure : result.getFailures()) {
System.err.println(failure.getTrace());
}
assertThat(result.getFailureCount()).isEqualTo(0); assertThat(result.getFailureCount()).isEqualTo(0);
assertThat(result.getRunCount()).isGreaterThan(0); assertThat(result.getRunCount()).isGreaterThan(0);
} }

@ -20,6 +20,7 @@ import org.junit.Test;
import org.junit.runner.JUnitCore; import org.junit.runner.JUnitCore;
import org.junit.runner.Result; import org.junit.runner.Result;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runner.notification.Failure;
import org.springframework.boot.junit.runner.classpath.ClassPathOverrides; import org.springframework.boot.junit.runner.classpath.ClassPathOverrides;
import org.springframework.boot.junit.runner.classpath.ModifiedClassPathRunner; import org.springframework.boot.junit.runner.classpath.ModifiedClassPathRunner;
@ -47,6 +48,9 @@ public class Mockito22Tests {
private void runTests(Class<?> testClass) { private void runTests(Class<?> testClass) {
Result result = new JUnitCore().run(testClass); Result result = new JUnitCore().run(testClass);
for (Failure failure : result.getFailures()) {
System.err.println(failure.getTrace());
}
assertThat(result.getFailureCount()).isEqualTo(0); assertThat(result.getFailureCount()).isEqualTo(0);
assertThat(result.getRunCount()).isGreaterThan(0); assertThat(result.getRunCount()).isGreaterThan(0);
} }

Loading…
Cancel
Save