use of org.junit.runners.model.TestClass in project junit4 by junit-team.
the class RuleMemberValidatorTest method methodRejectNonStaticClassRule.
@Test
public void methodRejectNonStaticClassRule() {
TestClass target = new TestClass(MethodTestWithNonStaticClassRule.class);
CLASS_RULE_METHOD_VALIDATOR.validate(target, errors);
assertOneErrorWithMessage("The @ClassRule 'getTemporaryFolder' must be static.");
}
use of org.junit.runners.model.TestClass in project Main by SpartanRefactoring.
the class MetaTester method runChild.
@Override
@SuppressWarnings("unused")
protected void runChild(final FrameworkMethod __, final RunNotifier n) {
if (hasRan)
return;
final Class<?> newTestClass = new ASTTestClassGenerator(testClass).generate(testClass.getSimpleName() + "_Meta", sourceFile);
final TestSuite suite = new TestSuite(newTestClass);
suite.run(new TestResult());
try {
new BlockJUnit4ClassRunnerWithParametersFactory().createRunnerForTestWithParameters(new TestWithParameters(" ", new TestClass(newTestClass), an.empty.list())).run(n);
} catch (final InitializationError ignore) {
/**/
}
// Uncomment this to run the original test as well
/* super.runChild(method, notifier); */
hasRan = true;
}
use of org.junit.runners.model.TestClass in project alchemy-test by SirWellington.
the class TestClassInjectorsTest method testPopulateGeneratedFieldsWithBadEnum.
@Test
public void testPopulateGeneratedFieldsWithBadEnum() throws Exception {
System.out.println("testPopulateGeneratedFieldsWithBadEnum");
TestClass testClass = new TestClass(BadEnumTest.class);
BadEnumTest instance = new BadEnumTest();
assertThrows(() -> TestClassInjectors.populateGeneratedFields(testClass, instance)).isInstanceOf(IllegalArgumentException.class);
}
use of org.junit.runners.model.TestClass in project alchemy-test by SirWellington.
the class TestClassInjectorsTest method testPopulateGeneratedFields.
@Test
public void testPopulateGeneratedFields() throws Exception {
System.out.println("testPopulateGeneratedFields");
TestClass testClass = new TestClass(FakeTestClass.class);
FakeTestClass instance = new FakeTestClass();
TestClassInjectors.populateGeneratedFields(testClass, instance);
instance.setUp();
}
use of org.junit.runners.model.TestClass in project intellij-community by JetBrains.
the class GuiTestRunner method loadClassesWithNewPluginClassLoader.
private void loadClassesWithNewPluginClassLoader() throws Exception {
//ensure that IDEA has been initialized.
IdeTestApplication.getInstance();
ParentPlugin testParentPluginAnnotation = getTestClass().getAnnotation(ParentPlugin.class);
assertNotNull(testParentPluginAnnotation);
String dependentPluginId = testParentPluginAnnotation.pluginId();
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
String classPath = getTestClass().getJavaClass().getCanonicalName().replace(".", "/").concat(".class");
URL resource = classLoader.getResource(classPath);
assertNotNull(resource);
String pathToTestClass = resource.getPath();
String containingFolderPath = pathToTestClass.substring(0, pathToTestClass.length() - classPath.length());
URL urlToTestClass = (new File(containingFolderPath)).toURI().toURL();
IdeaPluginDescriptor parentPluginDescriptor = PluginManager.getPlugin(PluginId.getId(dependentPluginId));
assertNotNull(parentPluginDescriptor);
ClassLoader parentPluginClassLoader = parentPluginDescriptor.getPluginClassLoader();
ClassLoader[] classLoaders = { parentPluginClassLoader };
String testPluginId = dependentPluginId + ".guitest";
PluginClassLoader testPluginClassLoader = new PluginClassLoader(Collections.singletonList(urlToTestClass), classLoaders, PluginId.getId(testPluginId), null, null);
Thread.currentThread().setContextClassLoader(testPluginClassLoader);
Class<?> testClass = getTestClass().getJavaClass();
myTestClass = new TestClass(testPluginClassLoader.loadClass(testClass.getName()));
}
Aggregations