Coverage Report - org.jbehave.core.embedder.PrintStreamEmbedderMonitor
 
Classes in this File Line Coverage Branch Coverage Complexity
PrintStreamEmbedderMonitor
100%
36/36
N/A
1
 
 1  
 package org.jbehave.core.embedder;
 2  
 
 3  
 import java.io.File;
 4  
 import java.io.PrintStream;
 5  
 import java.util.List;
 6  
 import java.util.Properties;
 7  
 
 8  
 import org.apache.commons.lang.builder.ToStringBuilder;
 9  
 import org.apache.commons.lang.builder.ToStringStyle;
 10  
 import org.jbehave.core.failures.BatchFailures;
 11  
 
 12  
 /**
 13  
  * Monitor that reports to a {@link PrintStream}, defaulting to
 14  
  * {@link System.out}
 15  
  */
 16  
 public class PrintStreamEmbedderMonitor implements EmbedderMonitor {
 17  
     private PrintStream output;
 18  
 
 19  
     public PrintStreamEmbedderMonitor() {
 20  48
         this(System.out);
 21  48
     }
 22  
 
 23  73
     public PrintStreamEmbedderMonitor(PrintStream output) {
 24  73
         this.output = output;
 25  73
     }
 26  
 
 27  
     public void batchFailed(BatchFailures failures) {
 28  3
         print("Failed to run batch " + failures);
 29  3
     }
 30  
 
 31  
     public void embeddableFailed(String name, Throwable cause) {
 32  1
         print("Failed to run embeddable " + name);
 33  1
         printStackTrace(cause);        
 34  1
     }
 35  
 
 36  
     public void embeddablesSkipped(List<String> classNames) {
 37  1
         print("Skipped embeddables "+classNames);        
 38  1
     }
 39  
 
 40  
     public void runningEmbeddable(String name) {
 41  14
         print("Running embeddable " + name);
 42  14
     }
 43  
 
 44  
     public void runningStory(String path) {
 45  23
         print("Running story " + path);
 46  23
     }
 47  
 
 48  
     public void storyFailed(String path, Throwable cause) {
 49  3
         print("Failed to run story " + path);
 50  3
         printStackTrace(cause);
 51  3
     }
 52  
 
 53  
     public void storiesSkipped(List<String> storyPaths) {
 54  1
         print("Skipped stories "+storyPaths);        
 55  1
     }
 56  
     
 57  
     public void annotatedInstanceNotOfType(Object annotatedInstance, Class<?> type) {
 58  1
         print("Annotated instance " + annotatedInstance + " if not of type " + type);
 59  1
     }
 60  
 
 61  
     public void generatingStoriesView(File outputDirectory, List<String> formats, Properties viewProperties) {
 62  21
         print("Generating stories view in '" + outputDirectory + "' using formats '" + formats + "'"
 63  
                 + " and view properties '" + viewProperties + "'");
 64  21
     }
 65  
 
 66  
     public void storiesViewGenerationFailed(File outputDirectory, List<String> formats, Properties viewProperties,
 67  
             Throwable cause) {
 68  1
         print("Failed to generate stories view in outputDirectory " + outputDirectory + " using formats " + formats
 69  
                 + " and view properties '" + viewProperties + "'");
 70  1
     }
 71  
 
 72  
     public void storiesViewGenerated(int stories, int scenarios, int failedScenarios) {
 73  20
         print("Stories view generated with " + stories + " stories containing " + scenarios + " scenarios (of which  "
 74  
                 + failedScenarios + " failed)");
 75  20
     }
 76  
 
 77  
     public void storiesViewNotGenerated() {
 78  1
         print("Stories view not generated");
 79  1
     }
 80  
 
 81  
     @Override
 82  
     public String toString() {
 83  2
         return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
 84  
     }
 85  
 
 86  
     protected void print(String message) {
 87  90
         output.println(message);
 88  90
     }
 89  
 
 90  
     protected void printStackTrace(Throwable e) {
 91  4
         e.printStackTrace(output);
 92  4
     }
 93  
 
 94  
 
 95  
 }