Request (final String parameterString, final String methodName, Class<?> clazz, RunWith clazzAnnotation) { if (clazzAnnotation == null) return null; final Class<? extends Runner> runnerClass = clazzAnnotation.value(); if (parameterString != null || isParameterized(methodName, clazz)) { try { if (methodName != null) { try { final Method method = clazz.getMethod(methodName); if (!method.isAnnotationPresent(Test.class) && TestCase.class.isAssignableFrom(clazz)) { return Request.runner(JUnit45ClassesRequestBuilder.createIgnoreAnnotationAndJUnit4ClassRunner(clazz)); } } catch (NoSuchMethodException ignore) { } } Class.forName("org.junit.runners.BlockJUnit4ClassRunner"); //ignore for junit4.4 and < final Constructor<? extends Runner> runnerConstructor = runnerClass.getConstructor(Class.class); return Request.runner(runnerConstructor.newInstance(clazz)).filterWith(new Filter() { @Override public boolean shouldRun(Description description) { final String descriptionMethodName = description.getMethodName(); //filter by params if (parameterString != null && descriptionMethodName != null && !descriptionMethodName.endsWith(parameterString)) { return false; } //filter only selected method if (methodName != null && descriptionMethodName != null && !descriptionMethodName.equals(methodName) && //If fork mode is used, a parameter is included in the name itself !isParameterizedMethodName(descriptionMethodName, methodName)) { return false; } return true; } @Override public String describe() { if (parameterString == null) { return methodName + " with any parameter"; } if (methodName == null) { return "Parameter " + parameterString + " for any method"; } return methodName + " with parameter " + parameterString; } }); } catch (Throwable throwable) { //return simple method runner } } return null; }