@Test
 public void should_report_all_errors() throws Throwable {
   try {
     softly.then(1).isEqualTo(1);
     softly.then(1).isEqualTo(2);
     softly.then(Lists.newArrayList(1, 2)).containsOnly(1, 3);
     MultipleFailureException.assertEmpty(softly.getErrors());
     fail("Should not reach here");
   } catch (MultipleFailureException e) {
     List<Throwable> failures = e.getFailures();
     assertThat(failures)
         .hasSize(2)
         .extracting("message")
         .contains(
             "expected:<[2]> but was:<[1]>",
             "\n"
                 + "Expecting:\n"
                 + "  <[1, 2]>\n"
                 + "to contain only:\n"
                 + "  <[1, 3]>\n"
                 + "elements not found:\n"
                 + "  <[3]>\n"
                 + "and elements not expected:\n"
                 + "  <[2]>\n");
   }
 }
Пример #2
0
 public void evaluate() throws Throwable {
   ArrayList localArrayList = new ArrayList();
   try {
     this.fNext.evaluate();
     Iterator localIterator1 = this.fAfters.iterator();
     while (localIterator1.hasNext()) {
       FrameworkMethod localFrameworkMethod1 = (FrameworkMethod) localIterator1.next();
       try {
         localFrameworkMethod1.invokeExplosively(this.fTarget, new Object[0]);
       } catch (Throwable localThrowable2) {
         localArrayList.add(localThrowable2);
       }
     }
     Iterator localIterator2;
     FrameworkMethod localFrameworkMethod2;
     Iterator localIterator3;
     FrameworkMethod localFrameworkMethod3;
     MultipleFailureException.assertEmpty(localArrayList);
   } catch (Throwable localThrowable1) {
     localArrayList.add(localThrowable1);
   } finally {
     localIterator3 = this.fAfters.iterator();
     while (localIterator3.hasNext()) {
       localFrameworkMethod3 = (FrameworkMethod) localIterator3.next();
       try {
         localFrameworkMethod3.invokeExplosively(this.fTarget, new Object[0]);
       } catch (Throwable localThrowable4) {
         localArrayList.add(localThrowable4);
       }
     }
   }
 }
 @Override
 public void evaluate() throws Throwable {
   List<Throwable> errors = new ArrayList<Throwable>();
   try {
     next.evaluate();
   } catch (Throwable e) {
     System.err.println(
         "THREAD DUMP FOR TEST FAILURE: \""
             + e.getMessage()
             + "\" at \""
             + method.getName()
             + "\"\n");
     try {
       System.err.println(generateThreadDump());
     } catch (Throwable t) {
       System.err.println("Unable to get thread dump!");
       e.printStackTrace();
     }
     errors.add(e);
   } finally {
     for (FrameworkMethod each : afters) {
       try {
         each.invokeExplosively(target);
       } catch (Throwable e) {
         errors.add(e);
       }
     }
   }
   MultipleFailureException.assertEmpty(errors);
 }