tests.trial.executors.process 2/3(66%) line coverage

      
10
20
30
40
50
60
70
80
90
100
110
120
130
145
155
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
880
890
900
910
920
930
940
950
960
970
980
990
1000
1010
1020
1030
1040
module tests.trial.executors.process; import std.datetime; import trial.executor.process; import trial.discovery.spec; import trial.reporters.visualtrial; import fluent.asserts; private string[] testHistory; void mockProcessExecutor(string suite, string testName, VisualTrialReporterParser parser) { testHistory ~= suite ~ ":" ~ testName; parser.testResult.status = TestResult.Status.success; } void pendingTest() { throw new PendingTestException(); } alias s = Spec!({ describe("The process executor", { ProcessExecutor executor; LifeCycleListeners listeners; beforeEach({ testHistory = []; executor = new ProcessExecutor(&mockProcessExecutor); listeners = LifeCycleListeners.instance; LifeCycleListeners.instance = new LifeCycleListeners(); LifeCycleListeners.instance.add(executor); }); afterEach({ LifeCycleListeners.instance = listeners; }); after({ LifeCycleListeners.instance = listeners; }); it("should call the process executor for a test", { auto testCase = const TestCase("Some.Suite", "test name", &pendingTest, []); executor.execute(testCase); testHistory.should.equal(["Some.Suite:test name"]); }); it("should return a suite result for a test case", { auto testCase = const TestCase("Some.Suite", "test name", &pendingTest, []); auto begin = Clock.currTime; executor.execute(testCase); auto result = executor.endExecution; result.length.should.equal(1); result[0].begin.should.be.greaterThan(begin); result[0].end.should.be.greaterThan(begin); result[0].name.should.equal("Some.Suite"); result[0].tests.length.should.equal(1); }); it("should return a test result for a test case", { auto location = SourceLocation(__FILE_FULL_PATH__, 50); auto testCase = const TestCase("Some.Suite", "test name", &pendingTest, [], location); auto begin = Clock.currTime; executor.execute(testCase); auto result = executor.endExecution[0].tests[0]; result.begin.should.be.greaterThan(begin); result.end.should.be.greaterThan(begin); result.name.should.equal("test name"); result.status.should.equal(TestResult.Status.success); result.fileName.should.endWith(__FILE__); result.line.should.equal(50); }); it("should return a suite result for two test cases with the same suite", { auto testCase1 = const TestCase("Some.Suite", "test name 1", &pendingTest, []); auto testCase2 = const TestCase("Some.Suite", "test name 2", &pendingTest, []); auto begin = Clock.currTime; auto result = executor.execute(testCase1); result.length.should.equal(0); result = executor.execute(testCase2); result.length.should.equal(0); result = executor.endExecution; result.length.should.equal(1); result[0].begin.should.be.greaterThan(begin); result[0].end.should.be.greaterThan(begin); result[0].name.should.equal("Some.Suite"); result[0].tests.length.should.equal(2); result[0].tests[0].name.should.equal("test name 1"); result[0].tests[1].name.should.equal("test name 2"); }); }); });