@Mock(reentrant = true) public boolean shouldRun(Filter filter, Object m) { testMethod = null; if (!coverageMap.isEmpty()) { if (m instanceof JUnit38ClassRunner) { boolean noTestsToRun = verifyTestMethodsInJUnit38TestClassThatShouldRun((JUnit38ClassRunner) m); if (noTestsToRun) { return false; } } else if (m instanceof FrameworkMethod) { testMethod = ((FrameworkMethod) m).getMethod(); Boolean shouldRun = shouldRunTestInCurrentTestRun(Test.class, testMethod); if (shouldRun != null) { return shouldRun; } } } Boolean shouldRun = MethodReflection.invoke(it, shouldRunMethod, filter, m); if (testMethod != null) { testMethods.put(testMethod, shouldRun); } return shouldRun; }
private void registerReplacementInstanceIfApplicable( @Nullable Object mock, @Nonnull ExpectedInvocation invocation) { Object replacementInstance = invocation.replacementInstance; if (replacementInstance != null && replacementInstance != invocation.instance) { replacementMap.put(mock, replacementInstance); } }
private Boolean shouldRunTestInCurrentTestRun( Class<? extends Annotation> testAnnotation, Method testMethod) { Boolean shouldRun = testMethods.get(testMethod); if (shouldRun != null) { return shouldRun; } if (isTestNotApplicableInCurrentTestRun(testAnnotation, testMethod)) { reportTestAsNotApplicableInCurrentTestRun(testMethod); testMethods.put(testMethod, false); return false; } return null; }
public void addTransformedClass( @Nonnull ClassIdentification classId, @Nonnull byte[] pretransformClassfile) { transformedClasses.put(classId, pretransformClassfile); }
public void registerInstanceFactoryForMockedType( @Nonnull Class<?> mockedType, @Nonnull InstanceFactory mockedInstanceFactory) { registerMockedClass(mockedType); mockedTypesAndInstances.put(mockedType, mockedInstanceFactory); }