private int getConstructorParameterCount() { List<ParameterSignature> signatures = ParameterSignature .signatures(clazz.getOnlyConstructor()); int constructorParameterCount = signatures.size(); return constructorParameterCount; }
/** * Returns a new fixture for running a test. Default implementation executes * the test class's no-argument constructor (validation should have ensured * one exists). */ protected Object createTest() throws Exception { return getTestClass().getOnlyConstructor().newInstance(); }
private int getConstructorParameterCount() { List<ParameterSignature> signatures = ParameterSignature .signatures(fClass.getOnlyConstructor()); int constructorParameterCount = signatures.size(); return constructorParameterCount; }
private Object createTestUsingConstructorInjection() throws Exception { return getTestClass().getOnlyConstructor().newInstance(parameters); }
/** * Returns a new fixture for running a test. Default implementation executes * the test class's no-argument constructor (validation should have ensured * one exists). */ protected Object createTest() throws Exception { return getTestClass().getOnlyConstructor().newInstance(); }
private Object createTestUsingConstructorInjection() throws Exception { return getTestClass().getOnlyConstructor().newInstance(fParameters); }
private Object createTestUsingConstructorInjection() throws Exception { return getTestClass().getOnlyConstructor().newInstance(parameters); }
@Override public Object createTest() throws Exception { return getTestClass().getOnlyConstructor().newInstance( complete.getConstructorArguments(nullsOk())); } }.methodBlock(fTestMethod).evaluate();
/** * Returns a new assignment list for {@code testMethod}, with no params * assigned. */ public static Assignments allUnassigned(Method testMethod, TestClass testClass) { List<ParameterSignature> signatures; signatures = ParameterSignature.signatures(testClass .getOnlyConstructor()); signatures.addAll(ParameterSignature.signatures(testMethod)); return new Assignments(new ArrayList<PotentialAssignment>(), signatures, testClass); }
/** * Returns a new assignment list for {@code testMethod}, with no params * assigned. */ public static Assignments allUnassigned(Method testMethod, TestClass testClass) throws Exception { List<ParameterSignature> signatures; signatures = ParameterSignature.signatures(testClass .getOnlyConstructor()); signatures.addAll(ParameterSignature.signatures(testMethod)); return new Assignments(new ArrayList<PotentialAssignment>(), signatures, testClass); }
/** * Adds to {@code errors} if the test class's single constructor takes * parameters (do not override) */ protected void validateZeroArgConstructor(List<Throwable> errors) { if (!getTestClass().isANonStaticInnerClass() && hasOneConstructor() && (getTestClass().getOnlyConstructor().getParameterTypes().length != 0)) { String gripe = "Test class should have exactly one public zero-argument constructor"; errors.add(new Exception(gripe)); } }
/** * Adds to {@code errors} if the test class's single constructor takes * parameters (do not override) */ protected void validateZeroArgConstructor(List<Throwable> errors) { if (!getTestClass().isANonStaticInnerClass() && hasOneConstructor() && (getTestClass().getOnlyConstructor().getParameterTypes().length != 0)) { String gripe = "Test class should have exactly one public zero-argument constructor"; errors.add(new Exception(gripe)); } }
@Override public Object createTest() throws Exception { Object[] params = complete.getConstructorArguments(); if (!nullsOk()) { Assume.assumeNotNull(params); } return getTestClass().getOnlyConstructor().newInstance(params); } }.methodBlock(testMethod).evaluate();
private RuleTst createTestClass() throws InitializationError { try { return (RuleTst) getTestClass().getOnlyConstructor().newInstance(); } catch (Exception e) { throw new InitializationError(e); } }
cachedInstance = getTestClass().getOnlyConstructor().newInstance();
private List<FrameworkMethod> getParametersMethods() throws Exception { List<FrameworkMethod> methods = getTestClass().getAnnotatedMethods( Parameterized.Parameters.class); SortedMap<Integer, FrameworkMethod> sortedMethods = new TreeMap<Integer, FrameworkMethod>(); for (FrameworkMethod each : methods) { if (each.isPublic()) { if (!each.isStatic()) { if (getTestClass().getOnlyConstructor().getParameterCount() != 0) { throw new Exception("Method " + each.getMethod() + " is annotated with @Parameters, it is not static and there is no parameter-less constructor!"); } } Order order = each.getAnnotation(Order.class); int value = order == null ? 0 : order.value(); FrameworkMethod prev = sortedMethods.put(value, each); if (prev != null) { throw new Exception(String.format("There are more methods annotated with @Parameters and @Order(value=%d): %s (%s) and %s (%s)", value, prev.getMethod(), prev.getAnnotation(Order.class), each.getMethod(), order)); } } else { throw new Exception("Method " + each.getMethod() + " is annotated with @Parameters but it is not public!"); } } if (sortedMethods.isEmpty()) { throw new Exception("No public static parameters method on class " + getTestClass().getName()); } return new ArrayList<FrameworkMethod>(sortedMethods.values()); }
/** * Returns a new fixture for running a test. Default implementation executes * the test class's no-argument constructor (validation should have ensured * one exists). */ protected Object createTest() throws Exception { return getTestClass().getOnlyConstructor().newInstance(); }
private int getConstructorParameterCount() { List<ParameterSignature> signatures = ParameterSignature .signatures(fClass.getOnlyConstructor()); int constructorParameterCount = signatures.size(); return constructorParameterCount; }
/** * Creates an instance of the current test class. When using a probe invoker, this simply * delegates to super. Otherwise, we perform injection on the instance created by the super * method. * <p> * In this case, an {@link InjectorFactory} is obtained via SPI lookup. */ @Override protected Object createTest() throws Exception { return getTestClass().getOnlyConstructor().newInstance(parameters); }
@Override public Object createTest() throws Exception { return getTestClass().getOnlyConstructor().newInstance( complete.getConstructorArguments(nullsOk())); } }.methodBlock(fTestMethod).evaluate();