use of org.junit.runners.model.FrameworkMethod in project restfuse by eclipsesource.
the class HttpJUnitRunner method computeTestMethods.
@Override
protected List<FrameworkMethod> computeTestMethods() {
ArrayList<FrameworkMethod> result = new ArrayList<FrameworkMethod>();
result.addAll(getTestClass().getAnnotatedMethods(HttpTest.class));
List<FrameworkMethod> testAnnotatedMethods = getTestClass().getAnnotatedMethods(Test.class);
for (FrameworkMethod method : testAnnotatedMethods) {
if (!result.contains(method)) {
result.add(method);
}
}
Collections.sort(result, new HttpOrderComparator());
return result;
}
use of org.junit.runners.model.FrameworkMethod in project materialistic by hidroh.
the class ParameterizedTestRunner method getParametersMethod.
private FrameworkMethod getParametersMethod() throws Exception {
TestClass testClass = getTestClass();
List<FrameworkMethod> methods = testClass.getAnnotatedMethods(Parameters.class);
for (FrameworkMethod each : methods) {
int modifiers = each.getMethod().getModifiers();
if (Modifier.isStatic(modifiers) && Modifier.isPublic(modifiers)) {
return each;
}
}
throw new Exception("No public static parameters method on class " + testClass.getName());
}
use of org.junit.runners.model.FrameworkMethod in project camel by apache.
the class CamelCdiRunner method getChildren.
@Override
protected List<FrameworkMethod> getChildren() {
List<FrameworkMethod> children = super.getChildren();
boolean hasDefinedOrder = false;
for (FrameworkMethod method : children) {
if (method.getAnnotation(Order.class) != null) {
hasDefinedOrder = true;
}
}
if (hasDefinedOrder) {
List<FrameworkMethod> sorted = new ArrayList<>(children);
Collections.sort(sorted, new FrameworkMethodSorter());
return sorted;
}
return children;
}
use of org.junit.runners.model.FrameworkMethod in project junit4 by junit-team.
the class ParentRunnerClassLoaderTest method testBackwardCompatibilityWithOverrideGetName.
@Test
public void testBackwardCompatibilityWithOverrideGetName() throws Exception {
final Class<TestWithClassRule> originalTestClass = TestWithClassRule.class;
final Class<?> waitClass = ParentRunnerClassLoaderTest.class;
ParentRunner<FrameworkMethod> subParentRunner = new BlockJUnit4ClassRunner(originalTestClass) {
@Override
protected String getName() {
return waitClass.getName();
}
};
Description description = subParentRunner.getDescription();
Class<?> result = description.getTestClass();
assertEquals("Subclass of ParentRunner can override getName method and specify another test class for run, " + "we should maintain backwards compatibility with JUnit 4.12", waitClass, result);
}
use of org.junit.runners.model.FrameworkMethod in project hazelcast by hazelcast.
the class AbstractHazelcastClassRunner method getTestRules.
@Override
protected List<TestRule> getTestRules(Object target) {
List<TestRule> testRules = super.getTestRules(target);
Set<Class<? extends TestRule>> testRuleClasses = new HashSet<Class<? extends TestRule>>();
TestClass testClass = getTestClass();
// find the required test rule classes from test class itself
Annotation[] classAnnotations = testClass.getAnnotations();
for (Annotation annotation : classAnnotations) {
Class<? extends Annotation> annotationType = annotation.annotationType();
AutoRegisteredTestRule autoFilterRule = annotationType.getAnnotation(AutoRegisteredTestRule.class);
if (autoFilterRule != null) {
Class<? extends TestRule> testRuleClass = autoFilterRule.testRule();
testRuleClasses.add(testRuleClass);
}
}
// find the required test rule classes from methods
List<FrameworkMethod> annotatedMethods = testClass.getAnnotatedMethods();
for (FrameworkMethod annotatedMethod : annotatedMethods) {
Annotation[] methodAnnotations = annotatedMethod.getAnnotations();
for (Annotation annotation : methodAnnotations) {
Class<? extends Annotation> annotationType = annotation.annotationType();
AutoRegisteredTestRule autoFilterRule = annotationType.getAnnotation(AutoRegisteredTestRule.class);
if (autoFilterRule != null) {
Class<? extends TestRule> testRuleClass = autoFilterRule.testRule();
testRuleClasses.add(testRuleClass);
}
}
}
// create and register test rules
for (Class<? extends TestRule> testRuleClass : testRuleClasses) {
try {
TestRule testRule = testRuleClass.newInstance();
testRules.add(testRule);
} catch (Throwable t) {
System.err.println("Unable to create test rule instance of test rule class " + testRuleClass.getName() + " because of " + t);
}
}
return testRules;
}
Aggregations