1020304050607080901001101201301401501601701801902002102202302402502602702802903003103203303433503633703803904004104204304404504604704844915015135215315405525625705805906006106206306406506606706806907017117207317417507617707827908008108208308418518608718818909019119209329409509609709809901001101110201031104110501061107010821090 /++ A module containing the ListReporter This is an example of how this reporter looks <script type="text/javascript" src="https://asciinema.org/a/b4u0o9vba18dquzdgwif7anl5.js" id="asciicast-b4u0o9vba18dquzdgwif7anl5" async></script> Copyright: © 2017 Szabo Bogdan License: Subject to the terms of the MIT license, as written in the included LICENSE.txt file. Authors: Szabo Bogdan +/ module trial.reporters.list; import std.stdio; import std.array; import std.conv; import std.datetime; import std.string; import std.algorithm; import trial.interfaces; import trial.settings; import trial.reporters.spec; import trial.reporters.writer; /// The list reporter outputs a simple specifications list as test cases pass or /// fail class ListReporter : SpecReporter { this(Settings settings) { super(settings); } this(ReportWriter writer) { super(writer); } override { void begin(string suite, ref TestResult) { } void end(string suite, ref TestResult test) { if(test.status == TestResult.Status.success) { write!(Type.success)("", 1); write!(Type.none)(suite ~ " " ~ test.name ~ "\n"); } else if(test.status == TestResult.Status.pending) { write!(Type.pending)("", 1); write!(Type.none)(suite ~ " " ~ test.name ~ "\n"); } else { write!(Type.failure)(suite ~ " " ~ test.name ~ "\n", 1); failedTests++; } } } } version (unittest) { import fluent.asserts; } @("it should print a sucess test") unittest { auto writer = new BufferedWriter; auto reporter = new ListReporter(writer); auto test = new TestResult("other test"); test.status = TestResult.Status.success; reporter.end("some suite", test); writer.buffer.should.equal(" ✓ some suite other test\n"); } @("it should print two failing tests") unittest { auto writer = new BufferedWriter; auto reporter = new ListReporter(writer); auto test = new TestResult("other test"); test.status = TestResult.Status.failure; reporter.end("some suite", test); reporter.end("some suite", test); writer.buffer.should.equal(" 0) some suite other test\n 1) some suite other test\n"); } @("it should print a pending test") unittest { auto writer = new BufferedWriter; auto reporter = new ListReporter(writer); auto test = new TestResult("other test"); test.status = TestResult.Status.pending; reporter.end("some suite", test); writer.buffer.should.equal(" - some suite other test\n"); }
/++ A module containing the ListReporter This is an example of how this reporter looks <script type="text/javascript" src="https://asciinema.org/a/b4u0o9vba18dquzdgwif7anl5.js" id="asciicast-b4u0o9vba18dquzdgwif7anl5" async></script> Copyright: © 2017 Szabo Bogdan License: Subject to the terms of the MIT license, as written in the included LICENSE.txt file. Authors: Szabo Bogdan +/ module trial.reporters.list; import std.stdio; import std.array; import std.conv; import std.datetime; import std.string; import std.algorithm; import trial.interfaces; import trial.settings; import trial.reporters.spec; import trial.reporters.writer; /// The list reporter outputs a simple specifications list as test cases pass or /// fail class ListReporter : SpecReporter { this(Settings settings) { super(settings); } this(ReportWriter writer) { super(writer); } override { void begin(string suite, ref TestResult) { } void end(string suite, ref TestResult test) { if(test.status == TestResult.Status.success) { write!(Type.success)("", 1); write!(Type.none)(suite ~ " " ~ test.name ~ "\n"); } else if(test.status == TestResult.Status.pending) { write!(Type.pending)("", 1); write!(Type.none)(suite ~ " " ~ test.name ~ "\n"); } else { write!(Type.failure)(suite ~ " " ~ test.name ~ "\n", 1); failedTests++; } } } } version (unittest) { import fluent.asserts; } @("it should print a sucess test") unittest { auto writer = new BufferedWriter; auto reporter = new ListReporter(writer); auto test = new TestResult("other test"); test.status = TestResult.Status.success; reporter.end("some suite", test); writer.buffer.should.equal(" ✓ some suite other test\n"); } @("it should print two failing tests") unittest { auto writer = new BufferedWriter; auto reporter = new ListReporter(writer); auto test = new TestResult("other test"); test.status = TestResult.Status.failure; reporter.end("some suite", test); reporter.end("some suite", test); writer.buffer.should.equal(" 0) some suite other test\n 1) some suite other test\n"); } @("it should print a pending test") unittest { auto writer = new BufferedWriter; auto reporter = new ListReporter(writer); auto test = new TestResult("other test"); test.status = TestResult.Status.pending; reporter.end("some suite", test); writer.buffer.should.equal(" - some suite other test\n"); }