use of org.junit.runners.model.TestClass 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));
}
use of org.junit.runners.model.TestClass in project ddf by codice.
the class PaxExamRule method starting.
private void starting(Description description) {
testsExecuted++;
String testClassName = description.getTestClass().getSimpleName();
if (setupFailed) {
fail(EXAM_SETUP_FAILED_MESSAGE);
}
TestClass testClass = new TestClass(description.getTestClass());
try {
runAnnotations(PostTestConstruct.class, testClass);
} catch (Throwable throwable) {
setupFailed = true;
failRule(testClassName, throwable, BEFORE_EXAM_FAILURE_MESSAGE);
}
if (firstRun) {
LOGGER.info("Starting test(s) for {}", testClassName);
firstRun = false;
testCount = getTestCount(testClass);
try {
runAnnotations(BeforeExam.class, testClass);
} catch (Throwable throwable) {
setupFailed = true;
LOGGER.error("Failed to setup " + testClassName, throwable);
failRule(testClassName, throwable, BEFORE_EXAM_FAILURE_MESSAGE);
}
}
LOGGER.info("Starting {} ({}/{})", description.getMethodName(), testsExecuted, testCount);
}
use of org.junit.runners.model.TestClass in project pact-jvm by DiUS.
the class HttpTarget method getProviderInfo.
protected ProviderInfo getProviderInfo() {
Provider provider = testClass.getAnnotation(Provider.class);
final ProviderInfo providerInfo = new ProviderInfo(provider.value());
providerInfo.setPort(port);
providerInfo.setHost(host);
providerInfo.setProtocol(protocol);
providerInfo.setPath(path);
providerInfo.setInsecure(insecure);
if (testClass != null) {
final List<FrameworkMethod> methods = testClass.getAnnotatedMethods(TargetRequestFilter.class);
if (!methods.isEmpty()) {
providerInfo.setRequestFilter((Consumer<HttpRequest>) httpRequest -> methods.forEach(method -> {
try {
method.invokeExplosively(testTarget, httpRequest);
} catch (Throwable t) {
throw new AssertionError("Request filter method " + method.getName() + " failed with an exception", t);
}
}));
}
}
return providerInfo;
}
use of org.junit.runners.model.TestClass in project junit4 by junit-team.
the class RuleMemberValidatorTest method acceptMethodStaticTestRuleThatIsAlsoClassRule.
@Test
public void acceptMethodStaticTestRuleThatIsAlsoClassRule() {
TestClass target = new TestClass(MethodTestWithStaticClassAndTestRule.class);
CLASS_RULE_METHOD_VALIDATOR.validate(target, errors);
assertNumberOfErrors(0);
}
use of org.junit.runners.model.TestClass in project junit4 by junit-team.
the class RuleMemberValidatorTest method methodRejectArbitraryObjectWithRuleAnnotation.
@Test
public void methodRejectArbitraryObjectWithRuleAnnotation() throws Exception {
TestClass target = new TestClass(MethodTestWithArbitraryObjectWithRuleAnnotation.class);
RULE_METHOD_VALIDATOR.validate(target, errors);
assertOneErrorWithMessage("The @Rule 'getArbitraryObject' must return an implementation of MethodRule or TestRule.");
}
Aggregations