private void addTestsFromTestCase(final Class<?> theClass) { fName = theClass.getName(); try { getTestConstructor(theClass); // Avoid generating multiple error messages } catch (NoSuchMethodException e) { addTest(warning("Class " + theClass.getName() + " has no public constructor TestCase(String name) or TestCase()")); return; } if (!Modifier.isPublic(theClass.getModifiers())) { addTest(warning("Class " + theClass.getName() + " is not public")); return; } Class<?> superClass = theClass; List<String> names = new ArrayList<String>(); while (Test.class.isAssignableFrom(superClass)) { for (Method each : MethodSorter.getDeclaredMethods(superClass)) { addTestMethod(each, names, theClass); } superClass = superClass.getSuperclass(); } if (fTests.size() == 0) { addTest(warning("No tests found in " + theClass.getName())); } }
private void addTestsFromTestCase(final Class<?> theClass) { fName = theClass.getName(); try { getTestConstructor(theClass); // Avoid generating multiple error messages } catch (NoSuchMethodException e) { addTest(warning("Class " + theClass.getName() + " has no public constructor TestCase(String name) or TestCase()")); return; } if (!Modifier.isPublic(theClass.getModifiers())) { addTest(warning("Class " + theClass.getName() + " is not public")); return; } Class<?> superClass = theClass; List<String> names = new ArrayList<String>(); while (Test.class.isAssignableFrom(superClass)) { for (Method each : MethodSorter.getDeclaredMethods(superClass)) { addTestMethod(each, names, theClass); } superClass = superClass.getSuperclass(); } if (fTests.size() == 0) { addTest(warning("No tests found in " + theClass.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 + " (" + 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; }
private void addTestsFromTestCase(final Class<?> theClass) { fName = theClass.getName(); try { getTestConstructor(theClass); // Avoid generating multiple error messages } catch (NoSuchMethodException e) { addTest(warning("Class " + theClass.getName() + " has no public constructor TestCase(String name) or TestCase()")); return; } if (!Modifier.isPublic(theClass.getModifiers())) { addTest(warning("Class " + theClass.getName() + " is not public")); return; } Class<?> superClass = theClass; List<String> names = new ArrayList<String>(); while (Test.class.isAssignableFrom(superClass)) { for (Method each : MethodSorter.getDeclaredMethods(superClass)) { addTestMethod(each, names, theClass); } superClass = superClass.getSuperclass(); } if (fTests.size() == 0) { addTest(warning("No tests found in " + theClass.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; }
boolean hasPublicConstructor(Class testClass) { try { TestSuite.getTestConstructor(testClass); } catch(NoSuchMethodException e) { return false; } return true; } }
boolean hasPublicConstructor(Class testClass) { try { TestSuite.getTestConstructor(testClass); } catch(NoSuchMethodException e) { return false; } return true; } }
boolean hasPublicConstructor(Class testClass) { try { TestSuite.getTestConstructor(testClass); } catch(NoSuchMethodException e) { return false; } return true; } }
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); } } }
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 void addTestsFromTestCase(final Class<?> theClass) { fName = theClass.getName(); try { getTestConstructor(theClass); // Avoid generating multiple error messages } catch (NoSuchMethodException e) { addTest(warning("Class " + theClass.getName() + " has no public constructor TestCase(String name) or TestCase()")); return; } if (!Modifier.isPublic(theClass.getModifiers())) { addTest(warning("Class " + theClass.getName() + " is not public")); return; } Class<?> superClass = theClass; List<String> names = new ArrayList<String>(); while (Test.class.isAssignableFrom(superClass)) { for (Method each : MethodSorter.getDeclaredMethods(superClass)) { addTestMethod(each, names, theClass); } superClass = superClass.getSuperclass(); } if (fTests.size() == 0) { addTest(warning("No tests found in " + theClass.getName())); } }
fName= theClass.getName(); try { getTestConstructor(theClass); // Avoid generating multiple error messages } catch (NoSuchMethodException e) { addTest(warning("Class "+theClass.getName()+" has no public constructor TestCase(String name) or TestCase()"));
private void addTestsFromTestCase(final Class<?> theClass) { fName = theClass.getName(); try { getTestConstructor(theClass); // Avoid generating multiple error messages } catch (NoSuchMethodException e) { addTest(warning("Class " + theClass.getName() + " has no public constructor TestCase(String name) or TestCase()")); return; } if (!Modifier.isPublic(theClass.getModifiers())) { addTest(warning("Class " + theClass.getName() + " is not public")); return; } Class<?> superClass = theClass; List<String> names = new ArrayList<String>(); while (Test.class.isAssignableFrom(superClass)) { for (Method each : MethodSorter.getDeclaredMethods(superClass)) { addTestMethod(each, names, theClass); } superClass = superClass.getSuperclass(); } if (fTests.size() == 0) { addTest(warning("No tests found in " + theClass.getName())); } }
private void addTestsFromTestCase(final Class<?> theClass) { fName = theClass.getName(); try { getTestConstructor(theClass); // Avoid generating multiple error messages } catch (NoSuchMethodException e) { addTest(warning("Class " + theClass.getName() + " has no public constructor TestCase(String name) or TestCase()")); return; } if (!Modifier.isPublic(theClass.getModifiers())) { addTest(warning("Class " + theClass.getName() + " is not public")); return; } Class<?> superClass = theClass; List<String> names = new ArrayList<String>(); while (Test.class.isAssignableFrom(superClass)) { for (Method each : MethodSorter.getDeclaredMethods(superClass)) { addTestMethod(each, names, theClass); } superClass = superClass.getSuperclass(); } if (fTests.size() == 0) { addTest(warning("No tests found in " + theClass.getName())); } }
private void addTestsFromTestCase(final Class<?> theClass) { fName = theClass.getName(); try { getTestConstructor(theClass); // Avoid generating multiple error messages } catch (NoSuchMethodException e) { addTest(warning("Class " + theClass.getName() + " has no public constructor TestCase(String name) or TestCase()")); return; } if (!Modifier.isPublic(theClass.getModifiers())) { addTest(warning("Class " + theClass.getName() + " is not public")); return; } Class<?> superClass = theClass; List<String> names = new ArrayList<String>(); while (Test.class.isAssignableFrom(superClass)) { for (Method each : MethodSorter.getDeclaredMethods(superClass)) { addTestMethod(each, names, theClass); } superClass = superClass.getSuperclass(); } if (fTests.size() == 0) { addTest(warning("No tests found in " + theClass.getName())); } }
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); } } }
/** * ...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; }
/** * ...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; }
/** * ...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; }