trial.step 0/14(0%) 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
340
350
360
370
380
390
400
410
420
430
440
450
460
470
480
490
500
510
520
530
540
550
560
570
580
590
600
610
620
630
640
650
660
670
680
690
700
710
720
730
740
750
760
770
780
790
800
810
820
830
840
850
860
870
/++ When you run complex tests, or tests that take a lot of time, it helps to mark certain areas as steps, to ease the debug or to improve the report. A good usage is for running BDD tests where a step can be steps from the `Gherkin Syntax` or UI Automation tests. 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.step; import trial.runner; import trial.interfaces; import std.datetime; import std.stdio; /** A stepstructure. Creating a Step will automatically be added to the current step as a child * The steps can be nested to allow you to group steps as with meanigful names. * * The steps ends when the Struct is destroyed. In order to have a step that represents a method * assign it to a local variable * * Examples: * ------------------------ * void TestSetup() @system * { * auto aStep = Step("Given some precondition"); * * Step("Some setup"); * performSomeSetup(); * * Step("Other setup"); * performOtherSetup(); * } * // will create this tree: * // Test * // | * // +- Given some precondition * // | * // +- Some setup * // +- Other setup * ------------------------ */ struct Step { static { /// The current suite name. Do not alter this global variable string suite; /// The current test name. Do not alter this global variable string test; } @disable this(); private { StepResult step; } /// Create and attach a step this(string name) { step = new StepResult; step.name = name; step.begin = Clock.currTime; step.end = Clock.currTime; if(LifeCycleListeners.instance is null) { writeln("Warning! Can not set steps if the LifeCycleListeners.instance is not set."); return; } LifeCycleListeners.instance.begin(suite, test, step); } /// Mark the test as finished ~this() { if(LifeCycleListeners.instance is null) { writeln("Warning! Can not set steps if the LifeCycleListeners.instance is not set."); return; } step.end = Clock.currTime; LifeCycleListeners.instance.end(suite, test, step); } }