/** * Returns the name that describes {@code method} for {@link Description}s. * Default implementation is the method's name */ protected String testName(FrameworkMethod method) { return method.getName(); }
@Override public String getDescription() throws CouldNotGenerateValueException { return method.getName(); } }
@Override public String getDescription() throws CouldNotGenerateValueException { return fMethod.getName(); } }
/** * Returns the name that describes {@code method} for {@link Description}s. * Default implementation is the method's name */ protected String testName(FrameworkMethod method) { return method.getName(); }
private FrameworkMethod findMethod(List<FrameworkMethod> methods, String methodName) { for (FrameworkMethod method : methods) { if (method.getName().equals(methodName)) { return method; } } return null; } }
protected void reportParameterizedError(Throwable e, Object... params) throws Throwable { if (params.length == 0) { throw e; } throw new ParameterizedAssertionError(e, testMethod.getName(), params); }
private static Exception parametersMethodReturnedWrongType( TestClass testClass, FrameworkMethod parametersMethod) throws Exception { String className = testClass.getName(); String methodName = parametersMethod.getName(); String message = MessageFormat.format( "{0}.{1}() must return an Iterable of arrays.", className, methodName); return new Exception(message); }
@Override protected String testName(FrameworkMethod method) { return method.getName() + getName(); }
public LoggedInvokeMethod(FrameworkMethod method, Object target) { super(method, target); this.method = method; name = method.getName(); }
protected void reportParameterizedError(Throwable e, Object... params) throws Throwable { if (params.length == 0) { throw e; } throw new ParameterizedAssertionError(e, fTestMethod.getName(), params); }
@Override protected String testName(FrameworkMethod method) { return method.getName() + getName(); }
@Override protected Statement methodBlock(FrameworkMethod method) { log.info( Test.class.getSimpleName() + ": " + method.getName() ); final Statement originalMethodBlock = super.methodBlock( method ); final ExtendedFrameworkMethod extendedFrameworkMethod = (ExtendedFrameworkMethod) method; return new FailureExpectedHandler( originalMethodBlock, testClassMetadata, extendedFrameworkMethod, testInstance ); }
private Exception parametersMethodReturnedWrongType() throws Exception { String className = getTestClass().getName(); String methodName = getParametersMethod().getName(); String message = MessageFormat.format( "{0}.{1}() must return an Iterable of arrays.", className, methodName); return new Exception(message); }
@Override public boolean isShadowedBy(FrameworkMethod other) { if (!other.getName().equals(getName())) { return false; } if (other.getParameterTypes().length != getParameterTypes().length) { return false; } for (int i = 0; i < other.getParameterTypes().length; i++) { if (!other.getParameterTypes()[i].equals(getParameterTypes()[i])) { return false; } } return true; }
@Override public void starting(FrameworkMethod method) { // By default, disable starting a JettyAdminServer in tests to avoid // accidentally attempting to start multiple admin servers on the // same port. System.setProperty("zookeeper.admin.enableServer", "false"); // ZOOKEEPER-2693 disables all 4lw by default. // Here we enable the 4lw which ZooKeeper tests depends. System.setProperty("zookeeper.4lw.commands.whitelist", "*"); testName = method.getName(); LOG.info("STARTING " + testName); }
private void validatePublicStaticVoidMethods( Class<? extends Annotation> annotation, Integer parameterCount, List<Throwable> errors) { List<FrameworkMethod> methods = getTestClass().getAnnotatedMethods(annotation); for (FrameworkMethod fm : methods) { fm.validatePublicVoid(true, errors); if (parameterCount != null) { int methodParameterCount = fm.getMethod().getParameterTypes().length; if (methodParameterCount != 0 && methodParameterCount != parameterCount) { errors.add(new Exception("Method " + fm.getName() + "() should have 0 or " + parameterCount + " parameter(s)")); } } } }
private void addMultiPointMethods(ParameterSignature sig, List<PotentialAssignment> list) { for (FrameworkMethod dataPointsMethod : fClass .getAnnotatedMethods(DataPoints.class)) { try { addMultiPointArrayValues(sig, dataPointsMethod.getName(), list, dataPointsMethod.invokeExplosively(null)); } catch (Throwable e) { // ignore and move on } } }
public void evaluate() throws Throwable { if (session == null) { session = Mockito.mockitoSession() .name(target.getClass().getSimpleName() + "." + method.getName()) .strictness(strictness) .logger(new MockitoSessionLoggerAdapter(logger)) .initMocks(target) .startMocking(); } else { MockitoAnnotations.initMocks(target); } Throwable testFailure = evaluateSafely(base); session.finishMocking(testFailure); if (testFailure != null) { throw testFailure; } }
@Test public void shouldAddApiLevelToNameOfAllButHighestNumberedMethodName() throws Throwable { runner = runnerOf(TestMethodUpToAndIncludingLollipop.class); assertThat(runner.getChildren().get(0).getName()).isEqualTo("testSomeApiLevel[16]"); assertThat(runner.getChildren().get(1).getName()).isEqualTo("testSomeApiLevel[17]"); assertThat(runner.getChildren().get(2).getName()).isEqualTo("testSomeApiLevel[18]"); assertThat(runner.getChildren().get(3).getName()).isEqualTo("testSomeApiLevel[19]"); assertThat(runner.getChildren().get(4).getName()).isEqualTo("testSomeApiLevel"); }