@Override public void setName(String name) { ppp("SETNAME " + name); super.setName(name); }
/** * ...as the moon sets over the early morning Merlin, Oregon * mountains, our intrepid adventurers type... */ static public Test createTest(Class<?> theClass, String name) { Constructor<?> constructor; try { constructor = getTestConstructor(theClass); } catch (NoSuchMethodException e) { return warning("Class " + theClass.getName() + " has no public constructor TestCase(String name) or TestCase()"); } Object test; try { if (constructor.getParameterTypes().length == 0) { test = constructor.newInstance(new Object[0]); if (test instanceof TestCase) { ((TestCase) test).setName(name); } } else { test = constructor.newInstance(new Object[]{name}); } } catch (InstantiationException e) { return (warning("Cannot instantiate test case: " + name + " (" + Throwables.getStacktrace(e) + ")")); } catch (InvocationTargetException e) { return (warning("Exception in constructor: " + name + " (" + Throwables.getStacktrace(e.getTargetException()) + ")")); } catch (IllegalAccessException e) { return (warning("Cannot access test case: " + name + " (" + Throwables.getStacktrace(e) + ")")); } return (Test) test; }
/** * ...as the moon sets over the early morning Merlin, Oregon * mountains, our intrepid adventurers type... */ static public Test createTest(Class<?> theClass, String name) { Constructor<?> constructor; try { constructor = getTestConstructor(theClass); } catch (NoSuchMethodException e) { return warning("Class " + theClass.getName() + " has no public constructor TestCase(String name) or TestCase()"); } Object test; try { if (constructor.getParameterTypes().length == 0) { test = constructor.newInstance(new Object[0]); if (test instanceof TestCase) { ((TestCase) test).setName(name); } } else { test = constructor.newInstance(new Object[]{name}); } } catch (InstantiationException e) { return (warning("Cannot instantiate test case: " + name + " (" + exceptionToString(e) + ")")); } catch (InvocationTargetException e) { return (warning("Exception in constructor: " + name + " (" + exceptionToString(e.getTargetException()) + ")")); } catch (IllegalAccessException e) { return (warning("Cannot access test case: " + name + " (" + exceptionToString(e) + ")")); } return (Test) test; }
} else { runner = new JUnit3Runner(instance); ((TestCase) instance).setName(child.getName());
/** * ...as the moon sets over the early morning Merlin, Oregon * mountains, our intrepid adventurers type... */ static public Test createTest(Class<?> theClass, String name) { Constructor<?> constructor; try { constructor = getTestConstructor(theClass); } catch (NoSuchMethodException e) { return warning("Class " + theClass.getName() + " has no public constructor TestCase(String name) or TestCase()"); } Object test; try { if (constructor.getParameterTypes().length == 0) { test = constructor.newInstance(new Object[0]); if (test instanceof TestCase) { ((TestCase) test).setName(name); } } else { test = constructor.newInstance(new Object[]{name}); } } catch (InstantiationException e) { return (warning("Cannot instantiate test case: " + name + " (" + exceptionToString(e) + ")")); } catch (InvocationTargetException e) { return (warning("Exception in constructor: " + name + " (" + exceptionToString(e.getTargetException()) + ")")); } catch (IllegalAccessException e) { return (warning("Cannot access test case: " + name + " (" + exceptionToString(e) + ")")); } return (Test) test; }
@Override public void setName(String name) { super.setName(name); }
@Override public void setName(String name) { super.setName(name); }
@Override public void setName(String name) { super.setName(name); }
@SuppressWarnings("unchecked") @Override public void runBare() throws Throwable { TestCase testCase = actualTestClass_.newInstance(); testCase.setName(getName()); actualTestClass_.getMethod("runBare0", new Class[0]).invoke(testCase, new Object[0]); }
private static Test createTest(final Class<? extends TestCase> clazz, final String name) { try { final Constructor<?> cons = TestSuite.getTestConstructor(clazz); if (cons.getParameterTypes().length == 1) { return (Test) cons.newInstance(name); } else { final TestCase test = (TestCase) cons.newInstance(); test.setName(name); return test; } } catch (final NoSuchMethodException e) { throw new RuntimeException("Failed to find constructor"); } catch (final InstantiationException e) { throw new RuntimeException(e); } catch (final IllegalAccessException e) { throw new RuntimeException(e); } catch (final IllegalArgumentException e) { throw new RuntimeException(e); } catch (final InvocationTargetException e) { throw new RuntimeException(e); } } }
@Override public void setName(String name) { super.setName(name); String[] fields = name.split(" ", 3); term1 = getTerm(fields[0]); operator = fields[1]; term2 = getTerm(fields[2]); }
private Test createTest(String testName, Class testClass) { Class[] classArgs= { String.class }; Test test; Constructor constructor= null; try { try { constructor= testClass.getConstructor(classArgs); test= (Test) constructor.newInstance(new Object[] { testName }); } catch (NoSuchMethodException e) { // try the no arg constructor supported in 3.8.1 constructor= testClass.getConstructor(new Class[0]); test= (Test) constructor.newInstance(new Object[0]); if (test instanceof TestCase) ((TestCase) test).setName(testName); } if (test != null) return test; } catch (InstantiationException e) { } catch (IllegalAccessException e) { } catch (InvocationTargetException e) { } catch (NoSuchMethodException e) { } catch (ClassCastException e) { } return error(testName, "Could not create test \'" + testName + "\' "); //$NON-NLS-1$ //$NON-NLS-2$ }
public static <T extends TestCase> Test createTestSuite(Class<T> clazz, Iterable<String> methodNames) { try { Constructor<T> constructor = getConstructor(clazz); junit.framework.TestSuite newSuite = new junit.framework.TestSuite(); for (String name : methodNames) { TestCase test; if (constructor.getParameterTypes().length == 0) { test = constructor.newInstance(); test.setName(name); } else { test = constructor.newInstance(name); } newSuite.addTest(test); } return newSuite; } catch (InstantiationException e) { throw new RuntimeException("Cannot instantiate test class " + clazz.getName(), e); } catch (IllegalAccessException e) { throw new RuntimeException(clazz.getName() + " constructor is not accessible", e); } catch (InvocationTargetException e) { throw new RuntimeException(clazz.getName() + "(String name) constructor threw an exception", e); } }
private Test createNewTestInstanceBasedOn(TestCase test) { TestCase newTest = null; try { Constructor constructor = getTestConstructor(test.getClass()); if (constructor.getParameterTypes().length == 0) { newTest = (TestCase)constructor.newInstance(new Object[0]); newTest.setName(test.getName()); } else { newTest = (TestCase)constructor.newInstance(new Object[]{test.getName()}); } } catch(Exception exc) { log.error(exc.getMessage(), exc); } return newTest; }
private Test createNewTestInstanceBasedOn(TestCase test) { TestCase newTest = null; try { Constructor constructor = getTestConstructor(test.getClass()); if (constructor.getParameterTypes().length == 0) { newTest = (TestCase)constructor.newInstance(new Object[0]); newTest.setName(test.getName()); } else { newTest = (TestCase)constructor.newInstance(new Object[]{test.getName()}); } } catch(Exception exc) { log.error(exc.getMessage(), exc); } return newTest; }
private static Test createTest(final Class<? extends TestCase> clazz, final String name) { try { final Constructor<?> cons = TestSuite.getTestConstructor(clazz); if (cons.getParameterTypes().length == 1) { return (Test) cons.newInstance(name); } else { final TestCase test = (TestCase) cons.newInstance(); test.setName(name); return test; } } catch (final NoSuchMethodException e) { throw new RuntimeException("Failed to find constructor"); } catch (final InstantiationException e) { throw new RuntimeException(e); } catch (final IllegalAccessException e) { throw new RuntimeException(e); } catch (final IllegalArgumentException e) { throw new RuntimeException(e); } catch (final InvocationTargetException e) { throw new RuntimeException(e); } } }
static private void addTests(TestSuite s, String dir, String base, String file) { TestCase tc = new StAX2ModelTest(dir, base, file); tc.setName("StAX " + tc.getName()); s.addTest(tc); } final String base;
static private void addTests(TestSuite s, String dir, String base, String file) { TestCase tc = new StAX2ModelTest(dir, base, file); tc.setName("StAX " + tc.getName()); s.addTest(tc); } final String base;