use of org.junit.runners.model.FrameworkMethod in project pinpoint by naver.
the class PinpointPluginTestRunner method filter.
@Override
public void filter(Filter filter) throws NoTestsRemainException {
synchronized (childrenLock) {
List<FrameworkMethod> children = new ArrayList<FrameworkMethod>(getFilteredChildren());
for (Iterator<FrameworkMethod> iter = children.iterator(); iter.hasNext(); ) {
FrameworkMethod each = iter.next();
if (shouldRun(filter, each)) {
try {
filter.apply(each);
} catch (NoTestsRemainException e) {
iter.remove();
}
} else {
iter.remove();
}
}
filteredChildren = Collections.unmodifiableCollection(children);
if (filteredChildren.isEmpty()) {
throw new NoTestsRemainException();
}
}
}
use of org.junit.runners.model.FrameworkMethod in project hibernate-orm by hibernate.
the class CustomParameterized method concatNames.
private String concatNames(List<FrameworkMethod> parametersMethods) {
StringBuilder sb = new StringBuilder();
for (FrameworkMethod method : parametersMethods) {
Parameterized.Parameters parameters = method.getAnnotation(Parameterized.Parameters.class);
if (sb.length() != 0) {
sb.append(", ");
}
sb.append(parameters.name());
}
return sb.toString();
}
use of org.junit.runners.model.FrameworkMethod in project hibernate-orm by hibernate.
the class CustomRunner method doComputation.
protected List<FrameworkMethod> doComputation() {
// Next, get all the test methods as understood by JUnit
final List<FrameworkMethod> methods = super.computeTestMethods();
// Now process that full list of test methods and build our custom result
final List<FrameworkMethod> result = new ArrayList<FrameworkMethod>();
final boolean doValidation = Boolean.getBoolean(Helper.VALIDATE_FAILURE_EXPECTED);
int testCount = 0;
Ignore virtualIgnore;
for (FrameworkMethod frameworkMethod : methods) {
// potentially ignore based on expected failure
final FailureExpected failureExpected = Helper.locateAnnotation(FailureExpected.class, frameworkMethod, getTestClass());
if (failureExpected != null && !doValidation) {
virtualIgnore = new IgnoreImpl(Helper.extractIgnoreMessage(failureExpected, frameworkMethod));
} else {
virtualIgnore = convertSkipToIgnore(frameworkMethod);
}
testCount++;
log.trace("adding test " + Helper.extractTestName(frameworkMethod) + " [#" + testCount + "]");
result.add(new ExtendedFrameworkMethod(frameworkMethod, virtualIgnore, failureExpected));
}
return result;
}
use of org.junit.runners.model.FrameworkMethod in project intellij-community by JetBrains.
the class GuiTestRunner method methodBlock.
@Override
protected Statement methodBlock(FrameworkMethod method) {
FrameworkMethod newMethod;
try {
if (Arrays.stream(getTestClass().getAnnotations()).anyMatch(annotation -> annotation instanceof ParentPlugin)) {
loadClassesWithNewPluginClassLoader();
} else {
loadClassesWithIdeClassLoader();
}
Method methodFromClassLoader = myTestClass.getJavaClass().getMethod(method.getName());
newMethod = new FrameworkMethod(methodFromClassLoader);
} catch (Exception e) {
return new Fail(e);
}
Object test;
try {
test = new ReflectiveCallable() {
@Override
protected Object runReflectiveCall() throws Throwable {
return createTest();
}
}.run();
} catch (Throwable e) {
return new Fail(e);
}
Statement statement = methodInvoker(newMethod, test);
List<FrameworkMethod> beforeMethods = myTestClass.getAnnotatedMethods(Before.class);
if (!beforeMethods.isEmpty()) {
statement = new RunBefores(statement, beforeMethods, test);
}
List<FrameworkMethod> afterMethods = myTestClass.getAnnotatedMethods(After.class);
if (!afterMethods.isEmpty()) {
statement = new RunAfters(statement, afterMethods, test);
}
return statement;
}
use of org.junit.runners.model.FrameworkMethod in project android by JetBrains.
the class GuiTestRunner method methodBlock.
@Override
protected Statement methodBlock(FrameworkMethod method) {
if (GraphicsEnvironment.isHeadless()) {
// checked first because IdeTestApplication.getInstance below (indirectly) throws an AWTException in a headless environment
return falseAssumption("headless environment");
}
Method methodFromClassLoader;
try {
ClassLoader ideClassLoader = IdeTestApplication.getInstance().getIdeClassLoader();
Thread.currentThread().setContextClassLoader(ideClassLoader);
myTestClass = new TestClass(ideClassLoader.loadClass(getTestClass().getJavaClass().getName()));
methodFromClassLoader = myTestClass.getJavaClass().getMethod(method.getName());
} catch (Exception e) {
return new Fail(e);
}
return super.methodBlock(new FrameworkMethod(methodFromClassLoader));
}
Aggregations