##### Coverage Report - org.jbehave.core.failures.BatchFailures

Classes in this File | Line Coverage | Branch Coverage | Complexity
BatchFailures |
82% | 14/17
75% | 3/4
| 1.5;1.5

1 |  |
     package org.jbehave.core.failures;
2 |  |
3 |  |
     import java.io.PrintWriter;
4 |  |
     import java.io.StringWriter;
5 |  |
     import java.util.HashMap;
6 |  |
7 |  |
     @SuppressWarnings("serial")
8 |  |
     public class BatchFailures extends HashMap<String, Throwable> {
9 |  |
10 |  |
         private final boolean verbose;
11 |  |
12 |  |
         public BatchFailures(){
13 | 3 |
             this(false);
14 | 3 |
         }
15 |  |
16 | 24 |
         public BatchFailures(boolean verbose) {
17 | 24 |
             this.verbose = verbose;
18 | 24 |
         }
19 |  |
20 |  |
         @Override
21 |  |
         public String toString() {
22 | 8 |
             StringBuffer sb = new StringBuffer();
23 | 8 |
             for (String name : keySet()) {
24 | 7 |
                 Throwable failure = get(name);
25 | 7 |
                 sb.append("\n");
26 | 7 |
                 sb.append(name);
27 | 7 |
                 sb.append(": ");
28 | 7 |
                 sb.append( verbose ? stackTraceOf(failure) : failure);
29 | 7 |
             }
30 | 8 |
             return sb.toString();
31 |  |
         }
32 |  |
33 |  |
         private String stackTraceOf(Throwable failure) {
34 | 0 |
             StringWriter writer = new StringWriter();
35 | 0 |
             failure.printStackTrace(new PrintWriter(writer));
36 | 0 |
             return writer.toString();
37 |  |
         }
38 |  |
39 |  |
     }