List<Method> getBefores() { return getAnnotatedMethods(BeforeClass.class); }
List<Method> getAfters() { return getAnnotatedMethods(AfterClass.class); }
List<Method> getAfters() { return testClass.getAnnotatedMethods(After.class); }
List<Method> getBefores() { return testClass.getAnnotatedMethods(Before.class); }
public List<Method> getTestMethods() { return getAnnotatedMethods(Test.class); }
List<Method> getAfters() { return fTestClass.getAnnotatedMethods(After.class); }
public List<Method> getTestMethods() { return getAnnotatedMethods(Test.class); }
List<Method> getBefores() { return getAnnotatedMethods(BeforeClass.class); }
List<Method> getAfters() { return getAnnotatedMethods(AfterClass.class); }
List<Method> getBefores() { return fTestClass.getAnnotatedMethods(Before.class); }
private void validateTestMethods(Class<? extends Annotation> annotation, boolean isStatic) { List<Method> methods = testClass.getAnnotatedMethods(annotation); for (Method each : methods) { if (Modifier.isStatic(each.getModifiers()) != isStatic) { String state = isStatic ? "should" : "should not"; errors.add(new Exception("Method " + each.getName() + "() " + state + " be static")); } if (!Modifier.isPublic(each.getDeclaringClass().getModifiers())) { errors.add(new Exception("Class " + each.getDeclaringClass().getName() + " should be public")); } if (!Modifier.isPublic(each.getModifiers())) { errors.add(new Exception("Method " + each.getName() + " should be public")); } if (each.getReturnType() != Void.TYPE) { errors.add(new Exception("Method " + each.getName() + "should have a return type of void")); } if (each.getParameterTypes().length != 0) { errors.add(new Exception("Method " + each.getName() + " should have no parameters")); } } } }
public void validateInstanceMethods() { validateTestMethods(After.class, false); validateTestMethods(Before.class, false); validateTestMethods(Test.class, false); List<Method> methods = testClass.getAnnotatedMethods(Test.class); if (methods.size() == 0) { errors.add(new Exception("No runnable methods")); } }
private void validateTestMethods(Class<? extends Annotation> annotation, boolean isStatic) { List<Method> methods = fTestClass.getAnnotatedMethods(annotation); for (Method each : methods) { if (Modifier.isStatic(each.getModifiers()) != isStatic) { String state = isStatic ? "should" : "should not"; fErrors.add(new Exception("Method " + each.getName() + "() " + state + " be static")); } if (!Modifier.isPublic(each.getDeclaringClass().getModifiers())) { fErrors.add(new Exception("Class " + each.getDeclaringClass().getName() + " should be public")); } if (!Modifier.isPublic(each.getModifiers())) { fErrors.add(new Exception("Method " + each.getName() + " should be public")); } if (each.getReturnType() != Void.TYPE) { fErrors.add(new Exception("Method " + each.getName() + " should be void")); } if (each.getParameterTypes().length != 0) { fErrors.add(new Exception("Method " + each.getName() + " should have no parameters")); } } } }
public void validateInstanceMethods() { validateTestMethods(After.class, false); validateTestMethods(Before.class, false); validateTestMethods(Test.class, false); List<Method> methods = fTestClass.getAnnotatedMethods(Test.class); if (methods.size() == 0) { fErrors.add(new Exception("No runnable methods")); } }
List<Method> getBefores() { return getAnnotatedMethods(BeforeClass.class); }
List<Method> getAfters() { return getAnnotatedMethods(AfterClass.class); }
List<Method> getAfters() { return fTestClass.getAnnotatedMethods(After.class); }
public List<Method> getTestMethods() { return getAnnotatedMethods(Test.class); }
List<Method> getBefores() { return fTestClass.getAnnotatedMethods(Before.class); }
public void validateInstanceMethods() { validateTestMethods(After.class, false); validateTestMethods(Before.class, false); validateTestMethods(Test.class, false); List<Method> methods = fTestClass.getAnnotatedMethods(Test.class); if (methods.size() == 0) { fErrors.add(new Exception("No runnable methods")); } }