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