1 module cucumber.formatter.progress; 2 3 import std.stdio : write, writeln; 4 5 import cucumber.formatter.base : Formatter; 6 import cucumber.formatter.color : colors, noColors; 7 import cucumber.result : Result, RunResult, ScenarioResult, StepResult; 8 import gherkin : Feature, Scenario, Step, Examples, TableRow, Comment; 9 10 /// 11 class Progress : Formatter 12 { 13 private bool noColor; 14 private bool noSnippets; 15 private bool noSource; 16 17 /// 18 this(bool noColor, bool noSnippets, bool noSource) 19 { 20 this.noColor = noColor; 21 this.noSnippets = noSnippets; 22 this.noSource = noSource; 23 } 24 25 /// 26 override string color(string result) 27 { 28 return noColor ? noColors[result] : colors[result]; 29 } 30 31 /// 32 override void feature(Feature feature) 33 { 34 // do nothing 35 } 36 37 /// 38 override void scenario(ref Scenario scenario) 39 { 40 // do nothing 41 } 42 43 /// 44 override void scenarioOutline(ref Scenario scenario) 45 { 46 // do nothing 47 } 48 49 /// 50 override void examples(Examples examples) 51 { 52 // do nothing 53 } 54 55 /// 56 override void tableRow(TableRow tableRow, ref TableRow[] table, string color) 57 { 58 // do nothing 59 } 60 61 /// 62 override void tableRow(TableRow tableRow, ref TableRow[] table, ScenarioResult scenarioResult) 63 { 64 // do nothing 65 } 66 67 /// 68 override void step(Step step, StepResult stepResult) 69 { 70 write(color(stepResult.result), progressSymbol(stepResult.result), color("reset")); 71 } 72 73 /// 74 override void emptyLine() 75 { 76 // do nothing 77 } 78 79 /// 80 override void comment(Comment comment) 81 { 82 // do nothing 83 } 84 85 /// 86 override void summarizeResult(RunResult result) 87 { 88 writeln("\n"); 89 runResult(result); 90 } 91 92 private: 93 string progressSymbol(string result) 94 { 95 immutable auto progressSymbols = [ 96 "failed" : `F`, "skipped" : `-`, "undefined" : `U`, "passed" : `.` 97 ]; 98 return progressSymbols[result]; 99 } 100 }