From a7bf9371566f973d7b2c474ae52781fc0ccbe5cf Mon Sep 17 00:00:00 2001
From: EdStrickland <2499128545@qq.com>
Date: Wed, 25 Mar 2020 01:15:58 +0800
Subject: [PATCH 01/23] Update browser.js
push assertion result to karma
---
lib/client/browser.js | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/lib/client/browser.js b/lib/client/browser.js
index 002d0e43..f92396bd 100644
--- a/lib/client/browser.js
+++ b/lib/client/browser.js
@@ -219,6 +219,14 @@ require("./discovery.js");
});
QUnit.log(function(details) {
+ const result = {
+ description: details.message,
+ suite: details.module && [qunitHtmlFile, details.module, details.name, details.message] || [],
+ success: details.result,
+ log: testResult.errors || [],
+ time: new Date().getTime() - timer
+ };
+ karma.result(result);
if (!details.result) {
let msg = "";
From 2e56125d08558c3e05f930fb4cdbbb40c89e573c Mon Sep 17 00:00:00 2001
From: EdStrickland <2499128545@qq.com>
Date: Thu, 26 Mar 2020 02:25:15 +0800
Subject: [PATCH 02/23] Update browser.js
---
lib/client/browser.js | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/lib/client/browser.js b/lib/client/browser.js
index f92396bd..93a2d8a2 100644
--- a/lib/client/browser.js
+++ b/lib/client/browser.js
@@ -219,14 +219,16 @@ require("./discovery.js");
});
QUnit.log(function(details) {
- const result = {
- description: details.message,
- suite: details.module && [qunitHtmlFile, details.module, details.name, details.message] || [],
- success: details.result,
- log: testResult.errors || [],
- time: new Date().getTime() - timer
- };
- karma.result(result);
+ if (config.logAllAssersions) {
+ const result = {
+ description: details.message,
+ suite: details.module && [qunitHtmlFile, details.module, details.name, details.message] || [],
+ success: details.result,
+ log: testResult.errors || [],
+ time: new Date().getTime() - timer
+ };
+ karma.result(result);
+ }
if (!details.result) {
let msg = "";
From b9605f35fbf02e65c2e5cf9fb400a541404c49d9 Mon Sep 17 00:00:00 2001
From: EdStrickland <2499128545@qq.com>
Date: Wed, 8 Apr 2020 15:42:59 +0800
Subject: [PATCH 03/23] Update browser.js
---
lib/client/browser.js | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/lib/client/browser.js b/lib/client/browser.js
index 93a2d8a2..940448df 100644
--- a/lib/client/browser.js
+++ b/lib/client/browser.js
@@ -219,16 +219,6 @@ require("./discovery.js");
});
QUnit.log(function(details) {
- if (config.logAllAssersions) {
- const result = {
- description: details.message,
- suite: details.module && [qunitHtmlFile, details.module, details.name, details.message] || [],
- success: details.result,
- log: testResult.errors || [],
- time: new Date().getTime() - timer
- };
- karma.result(result);
- }
if (!details.result) {
let msg = "";
@@ -248,6 +238,16 @@ require("./discovery.js");
testResult.success = false;
testResult.errors.push(msg);
}
+ if (config.logAssertions) {
+ const result = {
+ description: details.message,
+ suite: details.module && [qunitHtmlFile, details.module, details.name, details.message] || [],
+ success: details.result,
+ log: testResult.errors || [],
+ time: new Date().getTime() - timer
+ };
+ karma.result(result);
+ }
});
QUnit.testDone(function(test) {
From 377d7ff73e71ccf21b43b61663892e1aebc9786f Mon Sep 17 00:00:00 2001
From: EdStrickland <2499128545@qq.com>
Date: Thu, 23 Apr 2020 14:23:53 +0800
Subject: [PATCH 04/23] add integration tests(unfinished)
---
.../karma-reporter/formatter.js | 44 +++++++++++++
.../karma-reporter/index.js | 53 ++++++++++++++++
.../karma-reporter/writer.js | 16 +++++
.../application-log-assersion/karma.conf.js | 61 +++++++++++++++++++
.../application-log-assersion/webapp/foo.js | 3 +
.../webapp/manifest.json | 5 ++
.../webapp/test/test.qunit.html | 15 +++++
.../webapp/test/test.qunit.js | 15 +++++
.../webapp/test/testsuite.qunit.html | 10 +++
.../webapp/test/testsuite.qunit.js | 10 +++
10 files changed, 232 insertions(+)
create mode 100644 test/integration/application-log-assersion/karma-reporter/formatter.js
create mode 100644 test/integration/application-log-assersion/karma-reporter/index.js
create mode 100644 test/integration/application-log-assersion/karma-reporter/writer.js
create mode 100644 test/integration/application-log-assersion/karma.conf.js
create mode 100644 test/integration/application-log-assersion/webapp/foo.js
create mode 100644 test/integration/application-log-assersion/webapp/manifest.json
create mode 100644 test/integration/application-log-assersion/webapp/test/test.qunit.html
create mode 100644 test/integration/application-log-assersion/webapp/test/test.qunit.js
create mode 100644 test/integration/application-log-assersion/webapp/test/testsuite.qunit.html
create mode 100644 test/integration/application-log-assersion/webapp/test/testsuite.qunit.js
diff --git a/test/integration/application-log-assersion/karma-reporter/formatter.js b/test/integration/application-log-assersion/karma-reporter/formatter.js
new file mode 100644
index 00000000..4759d4d3
--- /dev/null
+++ b/test/integration/application-log-assersion/karma-reporter/formatter.js
@@ -0,0 +1,44 @@
+"use strict";
+
+var _ = require("lodash");
+
+module.exports = function (history) {
+ var cucumberJson = [];
+
+ _.forEach(history, function (feature, featureName) {
+ var elements = [];
+ var identifier = _.split(featureName, " ");
+ var tag = identifier[0];
+ var name = identifier.slice(1).join(" ");
+
+ _.forEach(feature, function (scenario, scenarioName) {
+ elements.push({
+ name: scenarioName,
+ type: "scenario",
+ keyword: "Scenario",
+ steps: _.map(scenario, function (step) {
+ return {
+ keyword: "",
+ name: step.description,
+ result: {
+ duration: step.time * 1000000,
+ status: step.success ? "passed" : "failed"
+ }
+ };
+ })
+ });
+ });
+
+ cucumberJson.push({
+ keyword: "Feature",
+ name: name,
+ uri: _.camelCase(name),
+ tags: [{
+ name: tag
+ }],
+ elements: elements
+ });
+ });
+
+ return cucumberJson;
+};
diff --git a/test/integration/application-log-assersion/karma-reporter/index.js b/test/integration/application-log-assersion/karma-reporter/index.js
new file mode 100644
index 00000000..1d642b4f
--- /dev/null
+++ b/test/integration/application-log-assersion/karma-reporter/index.js
@@ -0,0 +1,53 @@
+"use strict";
+
+var _ = require("lodash");
+
+var formatter = require("./formatter");
+var writer = require("./writer");
+
+var CucumberReporter = function (baseReporterDecorator, config, logger, helper) {
+ var log = logger.create("reporter.cucumber");
+ var reporterConfig = config.cucumberReporter || {};
+ var out = reporterConfig.out || "stdout";
+ var history = {};
+
+ baseReporterDecorator(this);
+
+ this.adapters = [function (msg) {
+ process.stdout.write.bind(process.stdout)(msg);
+ }];
+
+ this.onSpecComplete = function (browser, result) {
+ console.log("--------------------------------- debug ---------------------------------");
+ console.log(JSON.stringify(result));
+ var suite = result.suite[1];
+ var scenario = result.suite[2];
+ var step = result.suite[3];
+
+ if (!reporterConfig.prefix || reporterConfig.prefix && _.startsWith(suite, reporterConfig.prefix)) {
+ history[suite] = history[suite] || {};
+ history[suite][scenario] = history[suite][scenario] || [];
+ if (step) {
+ history[suite][scenario].push(result);
+ }
+ }
+ console.log("--------------------------------- debug ---------------------------------");
+ };
+
+ this.onRunComplete = function () {
+ var cucumberJson = formatter(history);
+ var jsonResult = JSON.stringify(cucumberJson, null, 2) + "\n";
+
+ if (out === "stdout") {
+ process.stdout.write(jsonResult);
+ } else {
+ writer(helper, out, log, jsonResult);
+ }
+ };
+};
+
+CucumberReporter.$inject = ["baseReporterDecorator", "config", "logger", "helper", "formatError"];
+
+module.exports = {
+ "reporter:cucumber": ["type", CucumberReporter]
+};
diff --git a/test/integration/application-log-assersion/karma-reporter/writer.js b/test/integration/application-log-assersion/karma-reporter/writer.js
new file mode 100644
index 00000000..d7380b83
--- /dev/null
+++ b/test/integration/application-log-assersion/karma-reporter/writer.js
@@ -0,0 +1,16 @@
+"use strict";
+
+var path = require("path");
+var fs = require("fs");
+
+module.exports = function (helper, out, log, jsonResult) {
+ helper.mkdirIfNotExists(path.dirname(out), function () {
+ fs.writeFile(out, jsonResult, function (err) {
+ if (err) {
+ log.error("Cannot write JSON\n\t" + err.message);
+ } else {
+ log.info("JSON written to %s", out);
+ }
+ });
+ });
+};
diff --git a/test/integration/application-log-assersion/karma.conf.js b/test/integration/application-log-assersion/karma.conf.js
new file mode 100644
index 00000000..b258888f
--- /dev/null
+++ b/test/integration/application-log-assersion/karma.conf.js
@@ -0,0 +1,61 @@
+const customCucumberReporter = require("./karma-reporter/index");
+const customKarmaUI5 = require("../../../lib/index");
+
+module.exports = function(config) {
+ "use strict";
+
+ require("../karma-base.conf")(config);
+ config.set({
+ plugins: [
+ "karma-chrome-launcher",
+ "karma-coverage",
+ customKarmaUI5,
+ customCucumberReporter
+ ],
+
+ ui5: {
+ type: "application",
+ mode: "html",
+ testpage: "webapp/test/test.qunit.html",
+ url: "http://localhost:" + config.localUI5ServerPort
+ },
+
+ frameworks: ["ui5"],
+
+ preprocessors: {
+ "{webapp,webapp/!(test)}/*.js": ["coverage"]
+ },
+ cucumberReporter: {
+ out: "cucumber.json",
+ prefix: "Feature"
+ },
+
+ coverageReporter: {
+ includeAllSources: true,
+ reporters: [
+ {
+ type: "json",
+ dir: "coverage",
+ subdir: "json"
+ }
+ ],
+ check: {
+ each: {
+ statements: 100,
+ branches: 100,
+ functions: 100,
+ lines: 100
+ }
+ }
+ },
+
+ reporters: ["progress", "coverage"]
+
+ });
+};
+
+module.exports.assertions = function({expect, log}) {
+ const coverage = require("./coverage/json/coverage-final.json");
+ const files = Object.keys(coverage);
+ expect(files).toHaveLength(1);
+};
diff --git a/test/integration/application-log-assersion/webapp/foo.js b/test/integration/application-log-assersion/webapp/foo.js
new file mode 100644
index 00000000..5aaa0e64
--- /dev/null
+++ b/test/integration/application-log-assersion/webapp/foo.js
@@ -0,0 +1,3 @@
+sap.ui.define(function() {
+ return "foo";
+});
diff --git a/test/integration/application-log-assersion/webapp/manifest.json b/test/integration/application-log-assersion/webapp/manifest.json
new file mode 100644
index 00000000..36e269f7
--- /dev/null
+++ b/test/integration/application-log-assersion/webapp/manifest.json
@@ -0,0 +1,5 @@
+{
+ "sap.app": {
+ "id": "sap.karma.ui5.test"
+ }
+}
diff --git a/test/integration/application-log-assersion/webapp/test/test.qunit.html b/test/integration/application-log-assersion/webapp/test/test.qunit.html
new file mode 100644
index 00000000..81aeffeb
--- /dev/null
+++ b/test/integration/application-log-assersion/webapp/test/test.qunit.html
@@ -0,0 +1,15 @@
+
+
+
+
+ QUnit Test
+
+
+
+
+
+
+
+
+
+
diff --git a/test/integration/application-log-assersion/webapp/test/test.qunit.js b/test/integration/application-log-assersion/webapp/test/test.qunit.js
new file mode 100644
index 00000000..64b61da5
--- /dev/null
+++ b/test/integration/application-log-assersion/webapp/test/test.qunit.js
@@ -0,0 +1,15 @@
+/* global QUnit */
+
+QUnit.config.autostart = false;
+
+sap.ui.getCore().attachInit(function() {
+ "use strict";
+
+ sap.ui.require(["test/app/foo"], function() {
+ QUnit.test("Karma", function(assert) {
+ assert.ok(parent.__karma__.files["/base/webapp/.dotfile"], "Karma files should contain dotfiles");
+ });
+
+ QUnit.start();
+ });
+});
diff --git a/test/integration/application-log-assersion/webapp/test/testsuite.qunit.html b/test/integration/application-log-assersion/webapp/test/testsuite.qunit.html
new file mode 100644
index 00000000..3153df14
--- /dev/null
+++ b/test/integration/application-log-assersion/webapp/test/testsuite.qunit.html
@@ -0,0 +1,10 @@
+
+
+
+ Testsuite
+
+
+
+
+
+
diff --git a/test/integration/application-log-assersion/webapp/test/testsuite.qunit.js b/test/integration/application-log-assersion/webapp/test/testsuite.qunit.js
new file mode 100644
index 00000000..ae283fc8
--- /dev/null
+++ b/test/integration/application-log-assersion/webapp/test/testsuite.qunit.js
@@ -0,0 +1,10 @@
+window.suite = function() {
+ "use strict";
+
+ // eslint-disable-next-line new-cap
+ const oSuite = new parent.jsUnitTestSuite();
+ const sContextPath = location.pathname.substring(0, location.pathname.lastIndexOf("/") + 1);
+ oSuite.addTestPage(sContextPath + "test.qunit.html");
+
+ return oSuite;
+};
From 62ca5dbdb70444415e50442e6407ce0ab35bb5a3 Mon Sep 17 00:00:00 2001
From: "2499128545@qq.com" <2499128545@qq.com>
Date: Wed, 6 May 2020 14:55:40 +0800
Subject: [PATCH 05/23] add integration tests and add config initialization
---
.gitignore | 2 +
lib/framework.js | 1 +
.../karma-reporter/index.js | 5 +-
.../application-log-assersion/karma.conf.js | 22 ++--
.../application-log-assersion/webapp/foo.js | 3 -
.../webapp/manifest.json | 5 -
.../webapp/test/GherkinTestRunner.html | 24 +++++
.../webapp/test/GherkinTestRunner.js | 21 ++++
.../webapp/test/Requirements1.feature | 23 ++++
.../webapp/test/Steps.js | 100 ++++++++++++++++++
.../webapp/test/Website.html | 15 +++
.../webapp/test/WebsiteCode.js | 44 ++++++++
.../webapp/test/manifest.json | 26 +++++
.../webapp/test/test.qunit.html | 15 ---
.../webapp/test/test.qunit.js | 15 ---
.../webapp/test/testsuite.qunit.html | 10 --
.../webapp/test/testsuite.qunit.js | 10 --
.../application-proxy/karma.conf.js | 5 +-
.../application-script-mode/karma.conf.js | 6 +-
.../karma.conf.js | 6 +-
.../application-ui5-tooling/karma.conf.js | 6 +-
test/integration/integration.test.js | 2 +-
.../library-custompath/karma.conf.js | 6 +-
test/integration/library-proxy/karma.conf.js | 6 +-
.../library-script-mode/karma.conf.js | 6 +-
.../library-tooling-script-mode/karma.conf.js | 6 +-
.../karma.conf.js | 6 +-
.../library-ui5-tooling/karma.conf.js | 7 +-
28 files changed, 322 insertions(+), 81 deletions(-)
delete mode 100644 test/integration/application-log-assersion/webapp/foo.js
delete mode 100644 test/integration/application-log-assersion/webapp/manifest.json
create mode 100644 test/integration/application-log-assersion/webapp/test/GherkinTestRunner.html
create mode 100644 test/integration/application-log-assersion/webapp/test/GherkinTestRunner.js
create mode 100644 test/integration/application-log-assersion/webapp/test/Requirements1.feature
create mode 100644 test/integration/application-log-assersion/webapp/test/Steps.js
create mode 100644 test/integration/application-log-assersion/webapp/test/Website.html
create mode 100644 test/integration/application-log-assersion/webapp/test/WebsiteCode.js
create mode 100644 test/integration/application-log-assersion/webapp/test/manifest.json
delete mode 100644 test/integration/application-log-assersion/webapp/test/test.qunit.html
delete mode 100644 test/integration/application-log-assersion/webapp/test/test.qunit.js
delete mode 100644 test/integration/application-log-assersion/webapp/test/testsuite.qunit.html
delete mode 100644 test/integration/application-log-assersion/webapp/test/testsuite.qunit.js
diff --git a/.gitignore b/.gitignore
index c760ecae..4004deb6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -56,3 +56,5 @@ deploy_key
# Custom directories
dist/
+
+cucumber.js
\ No newline at end of file
diff --git a/lib/framework.js b/lib/framework.js
index 4f90d3cf..8a49af53 100644
--- a/lib/framework.js
+++ b/lib/framework.js
@@ -116,6 +116,7 @@ class Framework {
// Relevant options (e.g. testpage, config, tests) will be written to the client section.
this.config.client.ui5 = {};
this.config.client.ui5.useIframe = true; // for now only allow using iframes in HTML mode
+ this.config.client.ui5.logAssertions = config.ui5 && config.ui5.logAssertions || false;
this.config.ui5 = config.ui5 || {};
this.config.proxies = config.proxies || {};
this.config.middleware = config.middleware || [];
diff --git a/test/integration/application-log-assersion/karma-reporter/index.js b/test/integration/application-log-assersion/karma-reporter/index.js
index 1d642b4f..47c5ff83 100644
--- a/test/integration/application-log-assersion/karma-reporter/index.js
+++ b/test/integration/application-log-assersion/karma-reporter/index.js
@@ -18,10 +18,8 @@ var CucumberReporter = function (baseReporterDecorator, config, logger, helper)
}];
this.onSpecComplete = function (browser, result) {
- console.log("--------------------------------- debug ---------------------------------");
- console.log(JSON.stringify(result));
var suite = result.suite[1];
- var scenario = result.suite[2];
+ var scenario = result.description;
var step = result.suite[3];
if (!reporterConfig.prefix || reporterConfig.prefix && _.startsWith(suite, reporterConfig.prefix)) {
@@ -31,7 +29,6 @@ var CucumberReporter = function (baseReporterDecorator, config, logger, helper)
history[suite][scenario].push(result);
}
}
- console.log("--------------------------------- debug ---------------------------------");
};
this.onRunComplete = function () {
diff --git a/test/integration/application-log-assersion/karma.conf.js b/test/integration/application-log-assersion/karma.conf.js
index b258888f..8d81a14e 100644
--- a/test/integration/application-log-assersion/karma.conf.js
+++ b/test/integration/application-log-assersion/karma.conf.js
@@ -16,8 +16,9 @@ module.exports = function(config) {
ui5: {
type: "application",
mode: "html",
- testpage: "webapp/test/test.qunit.html",
- url: "http://localhost:" + config.localUI5ServerPort
+ testpage: "webapp/test/GherkinTestRunner.html",
+ url: "http://localhost:" + config.localUI5ServerPort,
+ logAssertions: true
},
frameworks: ["ui5"],
@@ -26,8 +27,8 @@ module.exports = function(config) {
"{webapp,webapp/!(test)}/*.js": ["coverage"]
},
cucumberReporter: {
- out: "cucumber.json",
- prefix: "Feature"
+ out: "application-log-assersion/cucumber.json",
+ prefix: ""
},
coverageReporter: {
@@ -48,14 +49,19 @@ module.exports = function(config) {
}
}
},
+ autoWatch: false,
+ singleRun: true,
- reporters: ["progress", "coverage"]
+ reporters: ["progress", "coverage", "cucumber"]
});
};
module.exports.assertions = function({expect, log}) {
- const coverage = require("./coverage/json/coverage-final.json");
- const files = Object.keys(coverage);
- expect(files).toHaveLength(1);
+ const features = require("./cucumber.json");
+ const scenarios = features[0].elements;
+ const steps = scenarios[0].steps;
+ expect(features).toHaveLength(1);
+ expect(scenarios).toHaveLength(12);
+ expect(steps).toHaveLength(2);
};
diff --git a/test/integration/application-log-assersion/webapp/foo.js b/test/integration/application-log-assersion/webapp/foo.js
deleted file mode 100644
index 5aaa0e64..00000000
--- a/test/integration/application-log-assersion/webapp/foo.js
+++ /dev/null
@@ -1,3 +0,0 @@
-sap.ui.define(function() {
- return "foo";
-});
diff --git a/test/integration/application-log-assersion/webapp/manifest.json b/test/integration/application-log-assersion/webapp/manifest.json
deleted file mode 100644
index 36e269f7..00000000
--- a/test/integration/application-log-assersion/webapp/manifest.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "sap.app": {
- "id": "sap.karma.ui5.test"
- }
-}
diff --git a/test/integration/application-log-assersion/webapp/test/GherkinTestRunner.html b/test/integration/application-log-assersion/webapp/test/GherkinTestRunner.html
new file mode 100644
index 00000000..4e12672e
--- /dev/null
+++ b/test/integration/application-log-assersion/webapp/test/GherkinTestRunner.html
@@ -0,0 +1,24 @@
+
+
+
+
+ Using Gherkin with OPA5
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/integration/application-log-assersion/webapp/test/GherkinTestRunner.js b/test/integration/application-log-assersion/webapp/test/GherkinTestRunner.js
new file mode 100644
index 00000000..ae04cf07
--- /dev/null
+++ b/test/integration/application-log-assersion/webapp/test/GherkinTestRunner.js
@@ -0,0 +1,21 @@
+/* global QUnit */
+window.QUnit = {
+ config: {
+ autostart: false
+ }
+};
+
+sap.ui.require([
+ "sap/ui/test/gherkin/opa5TestHarness",
+ // Code coverage will be calculated for all modules loaded after the harness
+ "GherkinWithOPA5/Steps"
+], function(opa5TestHarness, Steps) {
+ "use strict";
+
+ opa5TestHarness.test({
+ featurePath: "GherkinWithOPA5.Requirements1",
+ steps: Steps
+ });
+
+ QUnit.start();
+});
diff --git a/test/integration/application-log-assersion/webapp/test/Requirements1.feature b/test/integration/application-log-assersion/webapp/test/Requirements1.feature
new file mode 100644
index 00000000..71211cee
--- /dev/null
+++ b/test/integration/application-log-assersion/webapp/test/Requirements1.feature
@@ -0,0 +1,23 @@
+Feature: Clicking Buttons Is a Life Saving Activity
+ Clicking buttons saves lemmings' lives. For the mere cost of a cheap home PC you
+ can save thousands of lemmings daily by clicking buttons all day long.
+
+ Background:
+ Given I have started the app
+ And I can see the life saving button
+
+ Scenario: Click a button, save a life!
+ Given I check how many lemmings have been saved already
+ When I click on the life saving button
+ Then I save a lemming's life
+
+ Scenario: The saved lemming has a name
+ When I click on the life saving button
+ Then I see Alice at the end of the list of named lemmings
+
+ @wip
+ Scenario: Lemmings don't really throw themselves off cliffs
+ Given there was a documentary of lemmings throwing themselves off a cliff
+ Given this film greatly affected people's perception of lemmings
+ Given this part of the film was faked
+ Then we expect the myth of suicide lemmings to persist despite its falsity
diff --git a/test/integration/application-log-assersion/webapp/test/Steps.js b/test/integration/application-log-assersion/webapp/test/Steps.js
new file mode 100644
index 00000000..8b3854d9
--- /dev/null
+++ b/test/integration/application-log-assersion/webapp/test/Steps.js
@@ -0,0 +1,100 @@
+sap.ui.define([
+ "sap/base/Log",
+ "sap/ui/test/gherkin/StepDefinitions",
+ "sap/ui/test/Opa5",
+ "sap/ui/test/actions/Press"
+], function(Log, StepDefinitions, Opa5, Press) {
+ "use strict";
+
+ var oOpa5 = new Opa5();
+
+ /**
+ * @param {function} fnCallback - executed once the number of lemmings saved is determined.
+ * Receives one parameter: "iNumberOfLemmingsSaved"
+ */
+ function getNumberOfLemmingsSaved(fnCallback) {
+ oOpa5.waitFor({
+ id: "num-lemmings-saved",
+ success: function(oLabel) {
+ var sNumberOfLemmingsSaved = oLabel.getText().match(/Number of lemmings saved: (\d+)/)[1];
+ var iNumberOfLemmingsSaved = parseInt(sNumberOfLemmingsSaved);
+ fnCallback(iNumberOfLemmingsSaved);
+ }
+ });
+ }
+
+ var Steps = StepDefinitions.extend("GherkinWithOPA5.Steps", {
+ init: function() {
+
+ this.register(/^I have started the app$/i, function() {
+ oOpa5.iStartMyAppInAFrame(sap.ui.require.toUrl("GherkinWithOPA5/Website.html"));
+ });
+
+ this.register(/^I can see the life saving button$/i, function() {
+ oOpa5.waitFor({
+ id: "life-saving-button",
+ success: function(oButton) {
+ Opa5.assert.strictEqual(oButton.getText(), "Save a Lemming",
+ "Verified that we can see the life saving button");
+ }
+ });
+ });
+
+ this.register(/^I check how many lemmings have been saved already$/i, function() {
+ getNumberOfLemmingsSaved(function(iNumberOfLemmingsSaved) {
+ this.iNumLemmings = iNumberOfLemmingsSaved;
+ }.bind(this));
+ });
+
+ this.register(/^I click on the life saving button\s*(\d*)?(?:\s*times)?$/i,
+ function(sNumTimes) {
+ var iNumTimes = (sNumTimes) ? parseInt(sNumTimes) : 1;
+ for (var i = 0; i < iNumTimes; ++i) {
+ oOpa5.waitFor({
+ id: "life-saving-button",
+ actions: new Press()
+ });
+ }
+ });
+
+ this.register(/^I save a lemming's life$/i, function() {
+ getNumberOfLemmingsSaved(function(iNumberOfLemmingsSaved) {
+ var iExpectedSavedLemmings = this.iNumLemmings + 1;
+ Opa5.assert.strictEqual(iNumberOfLemmingsSaved, iExpectedSavedLemmings,
+ "Verified correct number of lemmings saved");
+ }.bind(this));
+ });
+
+ this.register(/^I can see the following named lemmings:$/i, function(aDataTable) {
+ aDataTable.forEach(function(sLemmingName, iLemmingId) {
+ oOpa5.waitFor({
+ id: "lemming-name-" + (iLemmingId + 1),
+ success: function(oLabel) {
+ Opa5.assert.strictEqual(oLabel.getText(), sLemmingName,
+ "Verified lemming: " + sLemmingName);
+ }
+ });
+ });
+ });
+
+ this.register(/^I see (\w+) at the end of the list of named lemmings$/i, function(sName) {
+ oOpa5.waitFor({
+ id: "layout",
+ success: function(oLayout) {
+ var aContent = oLayout.getContent();
+ var oLastContentItem = aContent[aContent.length - 1];
+ Opa5.assert.strictEqual(oLastContentItem.getText(), sName,
+ "Verified lemming: " + sName);
+ }
+ });
+ });
+ },
+
+ closeApplication: function() {
+ Log.info("Closing application");
+ }
+ });
+
+ return Steps;
+
+});
\ No newline at end of file
diff --git a/test/integration/application-log-assersion/webapp/test/Website.html b/test/integration/application-log-assersion/webapp/test/Website.html
new file mode 100644
index 00000000..ef9e0e4c
--- /dev/null
+++ b/test/integration/application-log-assersion/webapp/test/Website.html
@@ -0,0 +1,15 @@
+
+
+ Using Gherkin with OPA5 Website
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test/integration/application-log-assersion/webapp/test/WebsiteCode.js b/test/integration/application-log-assersion/webapp/test/WebsiteCode.js
new file mode 100644
index 00000000..63c416ec
--- /dev/null
+++ b/test/integration/application-log-assersion/webapp/test/WebsiteCode.js
@@ -0,0 +1,44 @@
+sap.ui.getCore().attachInit(function() {
+ "use strict";
+
+ var sText = "Number of lemmings saved: ";
+ var iNumSavedLemmings = 0;
+
+ var oTitle = sap.m.Label({
+ id: "lemming-website-title",
+ text: "Lemming Life Saving Machine"
+ });
+
+ var oLabel = new sap.m.Label({
+ id: "num-lemmings-saved",
+ text: sText + iNumSavedLemmings
+ });
+
+ var aLemmingNames = ["Alice", "Bob", "Charlie", "David", "Elektra", "Felicia",
+ "Georgia", "Holly", "Idris", "Julien", "Kevin", "Lucia", "Michael", "Nancy",
+ "Oscar", "Peter", "Qubert", "Rascal", "Susan", "Terry", "Ursula", "Vicky",
+ "Walter", "Xavier", "Yolanda", "Zelda"];
+
+ var oLayout = new sap.ui.layout.VerticalLayout({id: "layout"});
+
+ var oButton = new sap.m.Button({
+ id: "life-saving-button",
+ text: "Save a Lemming",
+ press: function() {
+ iNumSavedLemmings += 1;
+ oLabel.setText(sText + iNumSavedLemmings);
+
+ var oNewLabel = new sap.m.Label({
+ id: "lemming-name-" + iNumSavedLemmings,
+ text: aLemmingNames[(iNumSavedLemmings - 1) % aLemmingNames.length]
+ });
+ oLayout.addContent(oNewLabel);
+ }
+ });
+
+ oLayout.addContent(oTitle);
+ oLayout.addContent(oButton);
+ oLayout.addContent(oLabel);
+ oLayout.placeAt("uiArea");
+
+});
\ No newline at end of file
diff --git a/test/integration/application-log-assersion/webapp/test/manifest.json b/test/integration/application-log-assersion/webapp/test/manifest.json
new file mode 100644
index 00000000..85cf4bb2
--- /dev/null
+++ b/test/integration/application-log-assersion/webapp/test/manifest.json
@@ -0,0 +1,26 @@
+{
+ "sap.app": {
+ "id": "sap.ui.core.sample.gherkin.GherkinWithOPA5",
+ "applicationVersion": {
+ "version": "1.0.0"
+ }
+ },
+ "sap.ui5": {
+ "config": {
+ "sample": {
+ "iframe": "GherkinTestRunner.html",
+ "stretch": true,
+ "files": [
+ "GherkinTestRunner.html",
+ "GherkinTestRunner.js",
+ "Requirements1.feature",
+ "Requirements2.feature",
+ "Steps.js",
+ "Website.html",
+ "WebsiteCode.js",
+ "manifest.json"
+ ]
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/test/integration/application-log-assersion/webapp/test/test.qunit.html b/test/integration/application-log-assersion/webapp/test/test.qunit.html
deleted file mode 100644
index 81aeffeb..00000000
--- a/test/integration/application-log-assersion/webapp/test/test.qunit.html
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
- QUnit Test
-
-
-
-
-
-
-
-
-
-
diff --git a/test/integration/application-log-assersion/webapp/test/test.qunit.js b/test/integration/application-log-assersion/webapp/test/test.qunit.js
deleted file mode 100644
index 64b61da5..00000000
--- a/test/integration/application-log-assersion/webapp/test/test.qunit.js
+++ /dev/null
@@ -1,15 +0,0 @@
-/* global QUnit */
-
-QUnit.config.autostart = false;
-
-sap.ui.getCore().attachInit(function() {
- "use strict";
-
- sap.ui.require(["test/app/foo"], function() {
- QUnit.test("Karma", function(assert) {
- assert.ok(parent.__karma__.files["/base/webapp/.dotfile"], "Karma files should contain dotfiles");
- });
-
- QUnit.start();
- });
-});
diff --git a/test/integration/application-log-assersion/webapp/test/testsuite.qunit.html b/test/integration/application-log-assersion/webapp/test/testsuite.qunit.html
deleted file mode 100644
index 3153df14..00000000
--- a/test/integration/application-log-assersion/webapp/test/testsuite.qunit.html
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
- Testsuite
-
-
-
-
-
-
diff --git a/test/integration/application-log-assersion/webapp/test/testsuite.qunit.js b/test/integration/application-log-assersion/webapp/test/testsuite.qunit.js
deleted file mode 100644
index ae283fc8..00000000
--- a/test/integration/application-log-assersion/webapp/test/testsuite.qunit.js
+++ /dev/null
@@ -1,10 +0,0 @@
-window.suite = function() {
- "use strict";
-
- // eslint-disable-next-line new-cap
- const oSuite = new parent.jsUnitTestSuite();
- const sContextPath = location.pathname.substring(0, location.pathname.lastIndexOf("/") + 1);
- oSuite.addTestPage(sContextPath + "test.qunit.html");
-
- return oSuite;
-};
diff --git a/test/integration/application-proxy/karma.conf.js b/test/integration/application-proxy/karma.conf.js
index e1b24963..53beb020 100644
--- a/test/integration/application-proxy/karma.conf.js
+++ b/test/integration/application-proxy/karma.conf.js
@@ -43,5 +43,8 @@ module.exports.assertions = function({expect, log}) {
const coverage = require("./coverage/json/coverage-final.json");
const files = Object.keys(coverage);
expect(files).toHaveLength(1);
- expect(files[0]).toEndWith("application-proxy/webapp/foo.js");
+ const sWindowsExpect = "application-proxy\\webapp\\foo.js";
+ const sLinuxExpect = "application-proxy/webapp/foo.js";
+ const sActual = files[0] && files[0].replace(sWindowsExpect, sLinuxExpect);
+ expect(sActual).toEndWith(sLinuxExpect);
};
diff --git a/test/integration/application-script-mode/karma.conf.js b/test/integration/application-script-mode/karma.conf.js
index db2cc404..f94418d8 100644
--- a/test/integration/application-script-mode/karma.conf.js
+++ b/test/integration/application-script-mode/karma.conf.js
@@ -58,5 +58,9 @@ module.exports.assertions = function({expect, log}) {
const coverage = require("./coverage/json/coverage-final.json");
const files = Object.keys(coverage);
expect(files).toHaveLength(1);
- expect(files[0]).toEndWith("application-script-mode/webapp/foo.js");
+
+ const sWindowsExpect = "application-script-mode\\webapp\\foo.js";
+ const sLinuxExpect = "application-script-mode/webapp/foo.js";
+ const sActual = files[0] && files[0].replace(sWindowsExpect, sLinuxExpect);
+ expect(sActual).toEndWith(sLinuxExpect);
};
diff --git a/test/integration/application-tooling-script-mode/karma.conf.js b/test/integration/application-tooling-script-mode/karma.conf.js
index 2446b535..7bca7bd7 100644
--- a/test/integration/application-tooling-script-mode/karma.conf.js
+++ b/test/integration/application-tooling-script-mode/karma.conf.js
@@ -57,5 +57,9 @@ module.exports.assertions = function({expect, log}) {
const coverage = require("./coverage/json/coverage-final.json");
const files = Object.keys(coverage);
expect(files).toHaveLength(1);
- expect(files[0]).toEndWith("application-tooling-script-mode/webapp/foo.js");
+
+ const sWindowsExpect = "application-tooling-script-mode\\webapp\\foo.js";
+ const sLinuxExpect = "application-tooling-script-mode/webapp/foo.js";
+ const sActual = files[0] && files[0].replace(sWindowsExpect, sLinuxExpect);
+ expect(sActual).toEndWith(sLinuxExpect);
};
diff --git a/test/integration/application-ui5-tooling/karma.conf.js b/test/integration/application-ui5-tooling/karma.conf.js
index 378dd3d2..d315788e 100644
--- a/test/integration/application-ui5-tooling/karma.conf.js
+++ b/test/integration/application-ui5-tooling/karma.conf.js
@@ -38,5 +38,9 @@ module.exports.assertions = function({expect, log}) {
const coverage = require("./coverage/json/coverage-final.json");
const files = Object.keys(coverage);
expect(files).toHaveLength(1);
- expect(files[0]).toEndWith("application-ui5-tooling/webapp/foo.js");
+
+ const sWindowsExpect = "application-ui5-tooling\\webapp\\foo.js";
+ const sLinuxExpect = "application-ui5-tooling/webapp/foo.js";
+ const sActual = files[0] && files[0].replace(sWindowsExpect, sLinuxExpect);
+ expect(sActual).toEndWith(sLinuxExpect);
};
diff --git a/test/integration/integration.test.js b/test/integration/integration.test.js
index d0832766..17ef2f7d 100644
--- a/test/integration/integration.test.js
+++ b/test/integration/integration.test.js
@@ -54,7 +54,7 @@ const registerIntegrationTest = async (configPath) => {
};
// Increase test timeout to 10s (default 5s)
-jest.setTimeout(10000);
+jest.setTimeout(100000);
beforeAll(async (done) => {
try {
diff --git a/test/integration/library-custompath/karma.conf.js b/test/integration/library-custompath/karma.conf.js
index 86c2d791..af526e30 100644
--- a/test/integration/library-custompath/karma.conf.js
+++ b/test/integration/library-custompath/karma.conf.js
@@ -47,5 +47,9 @@ module.exports.assertions = function({expect, log}) {
const coverage = require("./coverage/json/coverage-final.json");
const files = Object.keys(coverage);
expect(files).toHaveLength(1);
- expect(files[0]).toEndWith("library-custompath/src/main/js/sap/test/lib/library.js");
+
+ const sWindowsExpect = "library-custompath\\src\\main\\js\\sap\\test\\lib\\library.js";
+ const sLinuxExpect = "library-custompath/src/main/js/sap/test/lib/library.js";
+ const sActual = files[0] && files[0].replace(sWindowsExpect, sLinuxExpect);
+ expect(sActual).toEndWith(sLinuxExpect);
};
diff --git a/test/integration/library-proxy/karma.conf.js b/test/integration/library-proxy/karma.conf.js
index ae98974d..aeba3f84 100644
--- a/test/integration/library-proxy/karma.conf.js
+++ b/test/integration/library-proxy/karma.conf.js
@@ -43,5 +43,9 @@ module.exports.assertions = function({expect, log}) {
const coverage = require("./coverage/json/coverage-final.json");
const files = Object.keys(coverage);
expect(files).toHaveLength(1);
- expect(files[0]).toEndWith("library-proxy/src/sap/test/lib/library.js");
+
+ const sWindowsExpect = "library-proxy\\src\\sap\\test\\lib\\library.js";
+ const sLinuxExpect = "library-proxy/src/sap/test/lib/library.js";
+ const sActual = files[0] && files[0].replace(sWindowsExpect, sLinuxExpect);
+ expect(sActual).toEndWith(sLinuxExpect);
};
diff --git a/test/integration/library-script-mode/karma.conf.js b/test/integration/library-script-mode/karma.conf.js
index d244a929..f738a258 100644
--- a/test/integration/library-script-mode/karma.conf.js
+++ b/test/integration/library-script-mode/karma.conf.js
@@ -53,5 +53,9 @@ module.exports.assertions = function({expect, log}) {
const coverage = require("./coverage/json/coverage-final.json");
const files = Object.keys(coverage);
expect(files).toHaveLength(1);
- expect(files[0]).toEndWith("library-script-mode/src/sap/test/lib/library.js");
+
+ const sWindowsExpect = "library-script-mode\\src\\sap\\test\\lib\\library.js";
+ const sLinuxExpect = "library-script-mode/src/sap/test/lib/library.js";
+ const sActual = files[0] && files[0].replace(sWindowsExpect, sLinuxExpect);
+ expect(sActual).toEndWith(sLinuxExpect);
};
diff --git a/test/integration/library-tooling-script-mode/karma.conf.js b/test/integration/library-tooling-script-mode/karma.conf.js
index d2e331a0..a70171ba 100644
--- a/test/integration/library-tooling-script-mode/karma.conf.js
+++ b/test/integration/library-tooling-script-mode/karma.conf.js
@@ -51,5 +51,9 @@ module.exports.assertions = function({expect, log}) {
const coverage = require("./coverage/json/coverage-final.json");
const files = Object.keys(coverage);
expect(files).toHaveLength(1);
- expect(files[0]).toEndWith("library-tooling-script-mode/src/sap/test/lib/library.js");
+
+ const sWindowsExpect = "library-tooling-script-mode\\src\\sap\\test\\lib\\library.js";
+ const sLinuxExpect = "library-tooling-script-mode/src/sap/test/lib/library.js";
+ const sActual = files[0] && files[0].replace(sWindowsExpect, sLinuxExpect);
+ expect(sActual).toEndWith(sLinuxExpect);
};
diff --git a/test/integration/library-ui5-tooling-multiple-testsuites/karma.conf.js b/test/integration/library-ui5-tooling-multiple-testsuites/karma.conf.js
index 7bf25b79..6737c2ee 100644
--- a/test/integration/library-ui5-tooling-multiple-testsuites/karma.conf.js
+++ b/test/integration/library-ui5-tooling-multiple-testsuites/karma.conf.js
@@ -42,5 +42,9 @@ module.exports.assertions = function({expect, log}) {
const coverage = require("./coverage/json/coverage-final.json");
const files = Object.keys(coverage);
expect(files).toHaveLength(1);
- expect(files[0]).toEndWith("library-ui5-tooling-multiple-testsuites/src/sap/test/lib/library.js");
+
+ const sWindowsExpect = "library-ui5-tooling-multiple-testsuites\\src\\sap\\test\\lib\\library.js";
+ const sLinuxExpect = "library-ui5-tooling-multiple-testsuites/src/sap/test/lib/library.js";
+ const sActual = files[0] && files[0].replace(sWindowsExpect, sLinuxExpect);
+ expect(sActual).toEndWith(sLinuxExpect);
};
diff --git a/test/integration/library-ui5-tooling/karma.conf.js b/test/integration/library-ui5-tooling/karma.conf.js
index 341fa451..82aa2033 100644
--- a/test/integration/library-ui5-tooling/karma.conf.js
+++ b/test/integration/library-ui5-tooling/karma.conf.js
@@ -1,3 +1,4 @@
+
module.exports = function(config) {
"use strict";
@@ -38,5 +39,9 @@ module.exports.assertions = function({expect, log}) {
const coverage = require("./coverage/json/coverage-final.json");
const files = Object.keys(coverage);
expect(files).toHaveLength(1);
- expect(files[0]).toEndWith("library-ui5-tooling/src/sap/test/lib/library.js");
+
+ const sWindowsExpect = "library-ui5-tooling\\src\\sap\\test\\lib\\library.js";
+ const sLinuxExpect = "library-ui5-tooling/src/sap/test/lib/library.js";
+ const sActual = files[0] && files[0].replace(sWindowsExpect, sLinuxExpect);
+ expect(sActual).toEndWith(sLinuxExpect);
};
From 54001094973c909ea35ab6974afb9037aead6f4f Mon Sep 17 00:00:00 2001
From: "2499128545@qq.com" <2499128545@qq.com>
Date: Wed, 6 May 2020 15:24:58 +0800
Subject: [PATCH 06/23] fix eslint
---
.../karma-reporter/formatter.js | 72 ++++++++--------
.../karma-reporter/index.js | 84 +++++++++----------
.../karma-reporter/writer.js | 24 +++---
.../webapp/test/Steps.js | 31 +++----
.../webapp/test/WebsiteCode.js | 19 ++---
5 files changed, 115 insertions(+), 115 deletions(-)
diff --git a/test/integration/application-log-assersion/karma-reporter/formatter.js b/test/integration/application-log-assersion/karma-reporter/formatter.js
index 4759d4d3..4fb7be8f 100644
--- a/test/integration/application-log-assersion/karma-reporter/formatter.js
+++ b/test/integration/application-log-assersion/karma-reporter/formatter.js
@@ -1,44 +1,44 @@
"use strict";
-var _ = require("lodash");
+const _ = require("lodash");
-module.exports = function (history) {
- var cucumberJson = [];
+module.exports = function(history) {
+ const cucumberJson = [];
- _.forEach(history, function (feature, featureName) {
- var elements = [];
- var identifier = _.split(featureName, " ");
- var tag = identifier[0];
- var name = identifier.slice(1).join(" ");
+ _.forEach(history, function(feature, featureName) {
+ const elements = [];
+ const identifier = _.split(featureName, " ");
+ const tag = identifier[0];
+ const name = identifier.slice(1).join(" ");
- _.forEach(feature, function (scenario, scenarioName) {
- elements.push({
- name: scenarioName,
- type: "scenario",
- keyword: "Scenario",
- steps: _.map(scenario, function (step) {
- return {
- keyword: "",
- name: step.description,
- result: {
- duration: step.time * 1000000,
- status: step.success ? "passed" : "failed"
- }
- };
- })
- });
- });
+ _.forEach(feature, function(scenario, scenarioName) {
+ elements.push({
+ name: scenarioName,
+ type: "scenario",
+ keyword: "Scenario",
+ steps: _.map(scenario, function(step) {
+ return {
+ keyword: "",
+ name: step.description,
+ result: {
+ duration: step.time * 1000000,
+ status: step.success ? "passed" : "failed"
+ }
+ };
+ })
+ });
+ });
- cucumberJson.push({
- keyword: "Feature",
- name: name,
- uri: _.camelCase(name),
- tags: [{
- name: tag
- }],
- elements: elements
- });
- });
+ cucumberJson.push({
+ keyword: "Feature",
+ name: name,
+ uri: _.camelCase(name),
+ tags: [{
+ name: tag
+ }],
+ elements: elements
+ });
+ });
- return cucumberJson;
+ return cucumberJson;
};
diff --git a/test/integration/application-log-assersion/karma-reporter/index.js b/test/integration/application-log-assersion/karma-reporter/index.js
index 47c5ff83..412853ab 100644
--- a/test/integration/application-log-assersion/karma-reporter/index.js
+++ b/test/integration/application-log-assersion/karma-reporter/index.js
@@ -1,50 +1,50 @@
"use strict";
-var _ = require("lodash");
-
-var formatter = require("./formatter");
-var writer = require("./writer");
-
-var CucumberReporter = function (baseReporterDecorator, config, logger, helper) {
- var log = logger.create("reporter.cucumber");
- var reporterConfig = config.cucumberReporter || {};
- var out = reporterConfig.out || "stdout";
- var history = {};
-
- baseReporterDecorator(this);
-
- this.adapters = [function (msg) {
- process.stdout.write.bind(process.stdout)(msg);
- }];
-
- this.onSpecComplete = function (browser, result) {
- var suite = result.suite[1];
- var scenario = result.description;
- var step = result.suite[3];
-
- if (!reporterConfig.prefix || reporterConfig.prefix && _.startsWith(suite, reporterConfig.prefix)) {
- history[suite] = history[suite] || {};
- history[suite][scenario] = history[suite][scenario] || [];
- if (step) {
- history[suite][scenario].push(result);
- }
- }
- };
-
- this.onRunComplete = function () {
- var cucumberJson = formatter(history);
- var jsonResult = JSON.stringify(cucumberJson, null, 2) + "\n";
-
- if (out === "stdout") {
- process.stdout.write(jsonResult);
- } else {
- writer(helper, out, log, jsonResult);
- }
- };
+const _ = require("lodash");
+
+const formatter = require("./formatter");
+const writer = require("./writer");
+
+const CucumberReporter = function(baseReporterDecorator, config, logger, helper) {
+ const log = logger.create("reporter.cucumber");
+ const reporterConfig = config.cucumberReporter || {};
+ const out = reporterConfig.out || "stdout";
+ const history = {};
+
+ baseReporterDecorator(this);
+
+ this.adapters = [function(msg) {
+ process.stdout.write.bind(process.stdout)(msg);
+ }];
+
+ this.onSpecComplete = function(browser, result) {
+ const suite = result.suite[1];
+ const scenario = result.description;
+ const step = result.suite[3];
+
+ if (!reporterConfig.prefix || reporterConfig.prefix && _.startsWith(suite, reporterConfig.prefix)) {
+ history[suite] = history[suite] || {};
+ history[suite][scenario] = history[suite][scenario] || [];
+ if (step) {
+ history[suite][scenario].push(result);
+ }
+ }
+ };
+
+ this.onRunComplete = function() {
+ const cucumberJson = formatter(history);
+ const jsonResult = JSON.stringify(cucumberJson, null, 2) + "\n";
+
+ if (out === "stdout") {
+ process.stdout.write(jsonResult);
+ } else {
+ writer(helper, out, log, jsonResult);
+ }
+ };
};
CucumberReporter.$inject = ["baseReporterDecorator", "config", "logger", "helper", "formatError"];
module.exports = {
- "reporter:cucumber": ["type", CucumberReporter]
+ "reporter:cucumber": ["type", CucumberReporter]
};
diff --git a/test/integration/application-log-assersion/karma-reporter/writer.js b/test/integration/application-log-assersion/karma-reporter/writer.js
index d7380b83..dfe91d8c 100644
--- a/test/integration/application-log-assersion/karma-reporter/writer.js
+++ b/test/integration/application-log-assersion/karma-reporter/writer.js
@@ -1,16 +1,16 @@
"use strict";
-var path = require("path");
-var fs = require("fs");
+const path = require("path");
+const fs = require("fs");
-module.exports = function (helper, out, log, jsonResult) {
- helper.mkdirIfNotExists(path.dirname(out), function () {
- fs.writeFile(out, jsonResult, function (err) {
- if (err) {
- log.error("Cannot write JSON\n\t" + err.message);
- } else {
- log.info("JSON written to %s", out);
- }
- });
- });
+module.exports = function(helper, out, log, jsonResult) {
+ helper.mkdirIfNotExists(path.dirname(out), function() {
+ fs.writeFile(out, jsonResult, function(err) {
+ if (err) {
+ log.error("Cannot write JSON\n\t" + err.message);
+ } else {
+ log.info("JSON written to %s", out);
+ }
+ });
+ });
};
diff --git a/test/integration/application-log-assersion/webapp/test/Steps.js b/test/integration/application-log-assersion/webapp/test/Steps.js
index 8b3854d9..2f941c01 100644
--- a/test/integration/application-log-assersion/webapp/test/Steps.js
+++ b/test/integration/application-log-assersion/webapp/test/Steps.js
@@ -6,26 +6,25 @@ sap.ui.define([
], function(Log, StepDefinitions, Opa5, Press) {
"use strict";
- var oOpa5 = new Opa5();
+ const oOpa5 = new Opa5();
/**
- * @param {function} fnCallback - executed once the number of lemmings saved is determined.
+ * @param {Function} fnCallback - executed once the number of lemmings saved is determined.
* Receives one parameter: "iNumberOfLemmingsSaved"
*/
function getNumberOfLemmingsSaved(fnCallback) {
oOpa5.waitFor({
id: "num-lemmings-saved",
success: function(oLabel) {
- var sNumberOfLemmingsSaved = oLabel.getText().match(/Number of lemmings saved: (\d+)/)[1];
- var iNumberOfLemmingsSaved = parseInt(sNumberOfLemmingsSaved);
+ const sNumberOfLemmingsSaved = oLabel.getText().match(/Number of lemmings saved: (\d+)/)[1];
+ const iNumberOfLemmingsSaved = parseInt(sNumberOfLemmingsSaved);
fnCallback(iNumberOfLemmingsSaved);
}
});
}
- var Steps = StepDefinitions.extend("GherkinWithOPA5.Steps", {
+ const Steps = StepDefinitions.extend("GherkinWithOPA5.Steps", {
init: function() {
-
this.register(/^I have started the app$/i, function() {
oOpa5.iStartMyAppInAFrame(sap.ui.require.toUrl("GherkinWithOPA5/Website.html"));
});
@@ -43,13 +42,14 @@ sap.ui.define([
this.register(/^I check how many lemmings have been saved already$/i, function() {
getNumberOfLemmingsSaved(function(iNumberOfLemmingsSaved) {
this.iNumLemmings = iNumberOfLemmingsSaved;
+ /* eslint-disable */
}.bind(this));
+ /* eslint-enable */
});
- this.register(/^I click on the life saving button\s*(\d*)?(?:\s*times)?$/i,
- function(sNumTimes) {
- var iNumTimes = (sNumTimes) ? parseInt(sNumTimes) : 1;
- for (var i = 0; i < iNumTimes; ++i) {
+ this.register(/^I click on the life saving button\s*(\d*)?(?:\s*times)?$/i, function(sNumTimes) {
+ const iNumTimes = (sNumTimes) ? parseInt(sNumTimes) : 1;
+ for (let i = 0; i < iNumTimes; ++i) {
oOpa5.waitFor({
id: "life-saving-button",
actions: new Press()
@@ -59,10 +59,12 @@ sap.ui.define([
this.register(/^I save a lemming's life$/i, function() {
getNumberOfLemmingsSaved(function(iNumberOfLemmingsSaved) {
- var iExpectedSavedLemmings = this.iNumLemmings + 1;
+ const iExpectedSavedLemmings = this.iNumLemmings + 1;
Opa5.assert.strictEqual(iNumberOfLemmingsSaved, iExpectedSavedLemmings,
"Verified correct number of lemmings saved");
+ /* eslint-disable */
}.bind(this));
+ /* eslint-enable */
});
this.register(/^I can see the following named lemmings:$/i, function(aDataTable) {
@@ -81,8 +83,8 @@ sap.ui.define([
oOpa5.waitFor({
id: "layout",
success: function(oLayout) {
- var aContent = oLayout.getContent();
- var oLastContentItem = aContent[aContent.length - 1];
+ const aContent = oLayout.getContent();
+ const oLastContentItem = aContent[aContent.length - 1];
Opa5.assert.strictEqual(oLastContentItem.getText(), sName,
"Verified lemming: " + sName);
}
@@ -96,5 +98,4 @@ sap.ui.define([
});
return Steps;
-
-});
\ No newline at end of file
+});
diff --git a/test/integration/application-log-assersion/webapp/test/WebsiteCode.js b/test/integration/application-log-assersion/webapp/test/WebsiteCode.js
index 63c416ec..ba22b42e 100644
--- a/test/integration/application-log-assersion/webapp/test/WebsiteCode.js
+++ b/test/integration/application-log-assersion/webapp/test/WebsiteCode.js
@@ -1,34 +1,34 @@
sap.ui.getCore().attachInit(function() {
"use strict";
- var sText = "Number of lemmings saved: ";
- var iNumSavedLemmings = 0;
+ const sText = "Number of lemmings saved: ";
+ let iNumSavedLemmings = 0;
- var oTitle = sap.m.Label({
+ const oTitle = new sap.m.Label({
id: "lemming-website-title",
text: "Lemming Life Saving Machine"
});
- var oLabel = new sap.m.Label({
+ const oLabel = new sap.m.Label({
id: "num-lemmings-saved",
text: sText + iNumSavedLemmings
});
- var aLemmingNames = ["Alice", "Bob", "Charlie", "David", "Elektra", "Felicia",
+ const aLemmingNames = ["Alice", "Bob", "Charlie", "David", "Elektra", "Felicia",
"Georgia", "Holly", "Idris", "Julien", "Kevin", "Lucia", "Michael", "Nancy",
"Oscar", "Peter", "Qubert", "Rascal", "Susan", "Terry", "Ursula", "Vicky",
"Walter", "Xavier", "Yolanda", "Zelda"];
- var oLayout = new sap.ui.layout.VerticalLayout({id: "layout"});
+ const oLayout = new sap.ui.layout.VerticalLayout({id: "layout"});
- var oButton = new sap.m.Button({
+ const oButton = new sap.m.Button({
id: "life-saving-button",
text: "Save a Lemming",
press: function() {
iNumSavedLemmings += 1;
oLabel.setText(sText + iNumSavedLemmings);
- var oNewLabel = new sap.m.Label({
+ const oNewLabel = new sap.m.Label({
id: "lemming-name-" + iNumSavedLemmings,
text: aLemmingNames[(iNumSavedLemmings - 1) % aLemmingNames.length]
});
@@ -40,5 +40,4 @@ sap.ui.getCore().attachInit(function() {
oLayout.addContent(oButton);
oLayout.addContent(oLabel);
oLayout.placeAt("uiArea");
-
-});
\ No newline at end of file
+});
From 51c331b1d4a9a0446707736e9daa2b19f5308c3e Mon Sep 17 00:00:00 2001
From: EdStrickland <2499128545@qq.com>
Date: Thu, 28 May 2020 14:50:12 +0800
Subject: [PATCH 07/23] Update
test/integration/application-log-assersion/webapp/test/GherkinTestRunner.html
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Co-authored-by: Matthias Oßwald <1410947+matz3@users.noreply.github.com>
---
.../webapp/test/GherkinTestRunner.html | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/test/integration/application-log-assersion/webapp/test/GherkinTestRunner.html b/test/integration/application-log-assersion/webapp/test/GherkinTestRunner.html
index 4e12672e..93674544 100644
--- a/test/integration/application-log-assersion/webapp/test/GherkinTestRunner.html
+++ b/test/integration/application-log-assersion/webapp/test/GherkinTestRunner.html
@@ -5,7 +5,7 @@
Using Gherkin with OPA5
@@ -12,4 +12,4 @@
-