1 | "use strict";
|
2 | var html_reporter_1 = require("./reporters/html-reporter");
|
3 | var log_1 = require("./log");
|
4 | exports.EReportType = {
|
5 | NOTE: 'NOTE',
|
6 | WARNING: 'WARNING',
|
7 | ERROR: 'ERROR',
|
8 | };
|
9 | exports.EExecutionStep = {
|
10 | INIT: 'INIT',
|
11 | SCENARIO: 'SCENARIO',
|
12 | SETUP: 'SETUP',
|
13 | TEARDOWN: 'TEARDOWN',
|
14 | };
|
15 | var Reports = (function () {
|
16 | function Reports() {
|
17 | this._step = exports.EExecutionStep.INIT;
|
18 | this._reports = new Map();
|
19 | this._reports.set(exports.EExecutionStep.INIT, []);
|
20 | this._reports.set(exports.EExecutionStep.SCENARIO, []);
|
21 | this._reports.set(exports.EExecutionStep.SETUP, []);
|
22 | this._reports.set(exports.EExecutionStep.TEARDOWN, []);
|
23 | this._reporters = new Map();
|
24 | this._reporters.set('html', new html_reporter_1.HtmlReporter());
|
25 | }
|
26 | Reports.prototype._setStep = function (executionStep) {
|
27 | this._step = executionStep;
|
28 | };
|
29 | Reports.prototype._setTest = function (testData) {
|
30 | this._currentTestData = testData;
|
31 | };
|
32 | Reports.prototype._setInstanceNumber = function (instance) {
|
33 | this._instance = instance;
|
34 | };
|
35 | Reports.prototype.warning = function (params) {
|
36 | params.type = exports.EReportType.WARNING;
|
37 | this._report(params);
|
38 | };
|
39 | Reports.prototype.note = function (params) {
|
40 | params.type = exports.EReportType.NOTE;
|
41 | this._report(params);
|
42 | };
|
43 | Reports.prototype.error = function (params) {
|
44 | params.type = exports.EReportType.ERROR;
|
45 | this._report(params);
|
46 | };
|
47 | Reports.prototype._report = function (params) {
|
48 | params.timestamp = new Date();
|
49 | params.instance = this._instance;
|
50 | this._reports.get(this._step).push(params);
|
51 | };
|
52 | Reports.prototype.saveReport = function (reports, testName, reporters, path) {
|
53 | var _this = this;
|
54 | if (reporters.length === 0 || !path) {
|
55 | log_1.logDebug('No Strest reports configured...');
|
56 | return;
|
57 | }
|
58 | reporters.forEach(function (reporterName) {
|
59 | log_1.logDebug("Writing report using " + reporterName + " reporter...");
|
60 | var reporter = _this._reporters.get(reporterName);
|
61 | log_1.logDebug("Reporter " + reporterName + " exists: " + !!reporter);
|
62 | if (reporter) {
|
63 | reporter.writeTestReport(testName, reports, path);
|
64 | }
|
65 | });
|
66 | };
|
67 | return Reports;
|
68 | }());
|
69 | exports.Reports = Reports;
|
70 |
|
\ | No newline at end of file |