@Override protected void runWithIncompleteAssignment(Assignments incomplete) throws Throwable{ for(PotentialAssignment source:incomplete.potentialsForNextUnassigned()){ final Assignments nextAssignment = incomplete.assignNext(source); ForkJoinTask<?> run = new RecursiveAction(){ @Override protected void compute(){ try{ ParallelTheoryAnchor.this.runWithAssignment(nextAssignment); }catch(Throwable t){ throw new RuntimeException(t); } } }; runs.addFirst(run.fork()); } }
@Override public void evaluate() throws Throwable { runWithAssignment(Assignments.allUnassigned( fTestMethod.getMethod(), getTestClass())); //if this test method is not annotated with Theory, then no successes is a valid case boolean hasTheoryAnnotation = fTestMethod.getAnnotation(Theory.class) != null; if (successes == 0 && hasTheoryAnnotation) { Assert .fail("Never found parameters that satisfied method assumptions. Violated assumptions: " + fInvalidParameters); } }
protected void runWithAssignment(Assignments parameterAssignment) throws Throwable { if (!parameterAssignment.isComplete()) { runWithIncompleteAssignment(parameterAssignment); } else { runWithCompleteAssignment(parameterAssignment); } }
protected void runWithIncompleteAssignment(Assignments incomplete) throws Throwable { for (PotentialAssignment source : incomplete .potentialsForNextUnassigned()) { runWithAssignment(incomplete.assignNext(source)); } }
private Statement methodCompletesWithParameters( final FrameworkMethod method, final Assignments complete, final Object freshInstance) { return new Statement() { @Override public void evaluate() throws Throwable { final Object[] values = complete.getMethodArguments(); if (!nullsOk()) { Assume.assumeNotNull(values); } method.invokeExplosively(freshInstance, values); } }; }
@Override protected void runWithIncompleteAssignment(Assignments incomplete) throws Throwable { GuesserQueue guessers = createGuesserQueue(incomplete); queues.add(guessers); while (!guessers.isEmpty()) runWithAssignment(incomplete.assignNext(guessers.remove(0))); queues.remove(guessers); }
private GuesserQueue createGuesserQueue(Assignments incomplete) throws Throwable { ParameterSignature nextUnassigned = incomplete.nextUnassigned(); if (nextUnassigned.hasAnnotation(Stub.class)) { GuesserQueue queue = new GuesserQueue(); queue.add(new Guesser<Object>(nextUnassigned.getType())); return queue; } return GuesserQueue.forSingleValues(incomplete.potentialsForNextUnassigned()); }
@Override public void evaluate() throws Throwable { runWithAssignment(Assignments.allUnassigned( fTestMethod.getMethod(), getTestClass())); if (successes == 0) { Assert .fail("Never found parameters that satisfied method assumptions. Violated assumptions: " + fInvalidParameters); } }
protected void runWithIncompleteAssignment(Assignments incomplete) throws InstantiationException, IllegalAccessException, Throwable { for (PotentialAssignment source : incomplete .potentialsForNextUnassigned()) { runWithAssignment(incomplete.assignNext(source)); } }
private Statement methodCompletesWithParameters( final FrameworkMethod method, final Assignments complete, final Object freshInstance) { return new Statement() { @Override public void evaluate() throws Throwable { try { final Object[] values = complete.getMethodArguments( nullsOk()); method.invokeExplosively(freshInstance, values); } catch (CouldNotGenerateValueException e) { // ignore } } }; }
@Override protected void runWithIncompleteAssignment(Assignments incomplete) throws InstantiationException, IllegalAccessException, Throwable { GuesserQueue guessers = createGuesserQueue(incomplete); queues.add(guessers); while (!guessers.isEmpty()) runWithAssignment(incomplete.assignNext(guessers.remove(0))); queues.remove(guessers); }
private GuesserQueue createGuesserQueue(Assignments incomplete) throws InstantiationException, IllegalAccessException { ParameterSignature nextUnassigned = incomplete.nextUnassigned(); if (nextUnassigned.hasAnnotation(Stub.class)) { GuesserQueue queue = new GuesserQueue(); queue.add(new Guesser<Object>(nextUnassigned.getType())); return queue; } return GuesserQueue.forSingleValues(incomplete.potentialsForNextUnassigned()); }
public static List<PotentialAssignment> potentialAssignments(Method method) throws Throwable { return Assignments.allUnassigned(method, new TestClass(method.getDeclaringClass())) .potentialsForNextUnassigned(); }
private List<PotentialAssignment> potentialValues(Method method) throws Exception { return Assignments.allUnassigned(method, new TestClass(HasDateMethod.class)) .potentialsForNextUnassigned(); }