private void assertTestRuns(int... failingIndices) { IntByRef counter = new IntByRef(); TestResult result = new TestResult() { @Override public void testStarted(Test test) { super.testStarted(test); Assert.isInstanceOf(CountingTest.class, test); } }; new TestRunner(Iterators.iterable(new SimpleTestSuite(counter, NUM_TESTS, failingIndices))) .run(result); Assert.areEqual(NUM_TESTS, result.testCount()); Assert.areEqual(failingIndices.length, result.failures().size()); Assert.areEqual(NUM_TESTS + 2, counter.value); }
private Iterator4 checkDuplicates(CompositeIterator4 executeAllCandidates) { return Iterators.filter( executeAllCandidates, new Predicate4() { private TreeInt ids = new TreeInt(0); public boolean match(Object current) { int id = ((Integer) current).intValue(); if (ids.find(id) != null) { return false; } ids = (TreeInt) ids.add(new TreeInt(id)); return true; } }); }
public static void runTestAndExpect(Test test, int expFailures, boolean checkException) { runTestAndExpect(Iterators.singletonIterable(test), expFailures, checkException); }
public void testRunsRed() { TestResult result = new TestResult(); new TestRunner(Iterators.singletonIterable(new RunsRed(EXCEPTION))).run(result); Assert.isTrue(result.failures().size() == 1, "not red"); }
public void testRunsGreen() { TestResult result = new TestResult(); new TestRunner(Iterators.singletonIterable(new RunsGreen())).run(result); Assert.isTrue(result.failures().size() == 0, "not green"); }
public String toString() { return methodName + "(" + Iterators.join(Iterators.iterate(args), ", ") + ")"; }