コード例 #1
0
 public static void runTestAndExpect(
     final Iterable4 tests, int expFailures, boolean checkException) {
   final TestResult result = new TestResult();
   new TestRunner(tests).run(result);
   if (expFailures != result.failures().size()) {
     Assert.fail(result.failures().toString());
   }
   if (checkException) {
     for (Iterator4 iter = result.failures().iterator(); iter.moveNext(); ) {
       TestFailure failure = (TestFailure) iter.current();
       Assert.areEqual(EXCEPTION, failure.reason());
     }
   }
 }
コード例 #2
0
 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);
 }
コード例 #3
0
 public void testRunsRed() {
   TestResult result = new TestResult();
   new TestRunner(Iterators.singletonIterable(new RunsRed(EXCEPTION))).run(result);
   Assert.isTrue(result.failures().size() == 1, "not red");
 }
コード例 #4
0
 public void testRunsGreen() {
   TestResult result = new TestResult();
   new TestRunner(Iterators.singletonIterable(new RunsGreen())).run(result);
   Assert.isTrue(result.failures().size() == 0, "not green");
 }