trial.reporters.list 29/31(93%) line coverage

      
10
20
30
40
50
60
70
80
90
100
110
120
130
140
150
160
170
180
190
200
210
220
230
240
250
260
270
280
290
300
310
320
330
343
350
363
370
380
390
400
410
420
430
440
450
460
470
484
491
501
513
521
531
540
552
562
570
580
590
600
610
620
630
640
650
660
670
680
690
701
711
720
731
741
750
761
770
782
790
800
810
820
830
841
851
860
871
881
890
901
911
920
932
940
950
960
970
980
990
1001
1011
1020
1031
1041
1050
1061
1070
1082
1090
/++ 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"); }