-
Notifications
You must be signed in to change notification settings - Fork 25
Provide additional logging capabilities #161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 7 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
a7bf937
Update browser.js
EdStrickland 2e56125
Update browser.js
EdStrickland b9605f3
Update browser.js
EdStrickland 262a7d9
Merge pull request #1 from SAP/master
EdStrickland ccdef05
Merge pull request #2 from SAP/master
EdStrickland 377d7ff
add integration tests(unfinished)
EdStrickland 66ef536
Merge pull request #3 from EdStrickland/master
EdStrickland 62ca5db
add integration tests and add config initialization
EdStrickland 5400109
fix eslint
EdStrickland 51c331b
Update test/integration/application-log-assersion/webapp/test/Gherkin…
EdStrickland dde019c
Update test/integration/application-log-assersion/webapp/test/Website…
EdStrickland d0d11d8
Update test/integration/application-log-assersion/karma.conf.js
EdStrickland 98f551a
enhance config and integration tests
EdStrickland 9d37b93
fix bug`
EdStrickland 58b2d1c
fix gitignore
EdStrickland 7bbaa7a
bug fix
EdStrickland dadbdec
change ui5 resource to relative path
EdStrickland cc6117b
simplify mock OPA tests
EdStrickland d9973f5
simplify mock OPA tests
EdStrickland 72ceeef
fix check
EdStrickland e9f0660
add the flags in readme
EdStrickland afe9192
Merge branch 'master' into patch-1
EdStrickland 051d588
Merge branch 'master' into patch-1
EdStrickland d53933b
fix eslint
EdStrickland e4469d7
add setTimeout
EdStrickland ad18be1
testDone should log test module and test name instead of test obj
EdStrickland 63f4485
remove test obj from code
EdStrickland 775545d
fix ui5 tooling iframe path assertion fail on windows
EdStrickland File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
test/integration/application-log-assersion/karma-reporter/formatter.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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; | ||
| }; |
53 changes: 53 additions & 0 deletions
53
test/integration/application-log-assersion/karma-reporter/index.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| "use strict"; | ||
EdStrickland marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| var _ = require("lodash"); | ||
|
|
||
| var formatter = require("./formatter"); | ||
| var writer = require("./writer"); | ||
|
|
||
| var CucumberReporter = function (baseReporterDecorator, config, logger, helper) { | ||
EdStrickland marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 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] | ||
| }; | ||
16 changes: 16 additions & 0 deletions
16
test/integration/application-log-assersion/karma-reporter/writer.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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); | ||
| } | ||
| }); | ||
| }); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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: { | ||
EdStrickland marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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); | ||
EdStrickland marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| sap.ui.define(function() { | ||
| return "foo"; | ||
| }); |
5 changes: 5 additions & 0 deletions
5
test/integration/application-log-assersion/webapp/manifest.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "sap.app": { | ||
| "id": "sap.karma.ui5.test" | ||
| } | ||
| } |
15 changes: 15 additions & 0 deletions
15
test/integration/application-log-assersion/webapp/test/test.qunit.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <meta charset="utf-8"> | ||
| <title>QUnit Test</title> | ||
|
|
||
| <script id="sap-ui-bootstrap" src="../resources/sap-ui-core.js" data-sap-ui-resourceRoots='{ "test.app": "../" }'></script> | ||
| <link rel="stylesheet" href="../resources/sap/ui/thirdparty/qunit-2.css"> | ||
| <script src="../resources/sap/ui/thirdparty/qunit-2.js"></script> | ||
| <script src="./test.qunit.js"></script> | ||
| </head> | ||
| <body> | ||
| <div id="qunit"></div> | ||
| </body> | ||
| </html> |
15 changes: 15 additions & 0 deletions
15
test/integration/application-log-assersion/webapp/test/test.qunit.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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) { | ||
EdStrickland marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| assert.ok(parent.__karma__.files["/base/webapp/.dotfile"], "Karma files should contain dotfiles"); | ||
| }); | ||
|
|
||
| QUnit.start(); | ||
| }); | ||
| }); | ||
10 changes: 10 additions & 0 deletions
10
test/integration/application-log-assersion/webapp/test/testsuite.qunit.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <title>Testsuite</title> | ||
| <script src="../resources/sap/ui/qunit/qunit-redirect.js"></script> | ||
| <script src="testsuite.qunit.js" data-sap-ui-testsuite></script> | ||
| </head> | ||
| <body> | ||
| </body> | ||
| </html> |
10 changes: 10 additions & 0 deletions
10
test/integration/application-log-assersion/webapp/test/testsuite.qunit.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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; | ||
| }; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.