[英]How can I get coverage of protractor with cucumber
My project is build on Django and Angular. 我的项目是基于Django和Angular构建的。
I use protractor with cucumber and chai as my e2e test. 我用黄瓜和柴的量角器作为我的e2e测试。
And using "grunt-protractor-coverage" to report code coverage. 并使用“grunt-protractor-coverage”报告代码覆盖率。 I have question here that if I use jasmine as protractor framework, when I run "grunt test" it's just fine.
我在这里有一个问题,如果我使用茉莉花作为量角器框架,当我运行“咕噜咕噜测试”时,它就好了。 But when I use cucumber, error happens.
但是当我使用黄瓜时,会发生错误。
[launcher] Process exited with error code 1 /Users/paizanmay/Documents/ichef/Superadmin2.0/node_modules/protractor/node_modules/q/q.js:126 throw e; ^ Error: Spec patterns did not match any files. at Runner.run (/Users/paizanmay/Documents/ichef/Superadmin2.0/node_modules/protractor/lib/runner.js:249:11) at TaskRunner.run (/Users/paizanmay/Documents/ichef/Superadmin2.0/node_modules/protractor/lib/taskRunner.js:123:19) at createNextTaskRunner (/Users/paizanmay/Documents/ichef/Superadmin2.0/node_modules/protractor/lib/launcher.js:220:20) at /Users/paizanmay/Documents/ichef/Superadmin2.0/node_modules/protractor/lib/launcher.js:243:7 at _fulfilled (/Users/paizanmay/Documents/ichef/Superadmin2.0/node_modules/protractor/node_modules/q/q.js:797:54) at self.promiseDispatch.done (/Users/paizanmay/Documents/ichef/Superadmin2.0/node_modules/protractor/node_modules/q/q.js:826:30) at Promise.promise.promiseDispatch (/Users/paizanmay/Documents/ichef/Superadmin2.0/node_modules/protractor/node_modules/q/q.js:759:13) at /Users/paizanmay/Documents/ichef/Superadmin2.0/node_modules/protractor/node_modules/q/q.js:573:44 at flush (/Users/paizanmay/Documents/ichef/Superadmin2.0/node_modules/protractor/node_modules/q/q.js:108:17) at process._tickCallback (node.js:355:11)
I really don't know how to solve it 我真的不知道如何解决它
Is "specs: ['features/store_id_admin.feature']," useless in "grunt-protractor-coverage" ? 是“specs:['features / store_id_admin.feature'],”grunt-protractor-coverage中无用“?
thx 谢谢
It doesn't look like grunt-protractor-coverage was designed to work with CucumberJS. 它看起来不像grunt-protractor-coverage旨在与CucumberJS一起使用。 Whilst I managed to get it to read my spec list (I moved protractor.conf.js to the root of my app and specified full paths) the plugin expects specs to written as JavaScript so that they can be rewritten to collect/push coverage data back.
虽然我设法让它读取我的规范列表(我将protractor.conf.js移动到我的应用程序的根目录并指定了完整路径),但该插件希望将规范编写为JavaScript,以便可以重写它们以收集/推送覆盖数据背部。 When your tests run a small service runs in the background (coverage-collector) to collate the coverage data from each scenario.
当您的测试运行时,一个小型服务在后台(coverage-collector)运行,以整理每个方案的覆盖率数据。
In theory CucumberJS also provides similar hooks that could be specified along with the step definitions to record the data from window.__coverage__
object after each feature/step: https://github.com/cucumber/cucumber-js#after-hooks 理论上,CucumberJS还提供类似的钩子,可以与步骤定义一起指定,以便在每个特征/步骤之后记录来自
window.__coverage__
对象的数据: https : //github.com/cucumber/cucumber-js#after-hooks
(You can see the template used to write coverage data to the collector here: https://github.com/r3b/grunt-protractor-coverage/blob/master/resources/saveCoverage.tmpl ) (您可以在此处看到用于将覆盖数据写入收集器的模板: https : //github.com/r3b/grunt-protractor-coverage/blob/master/resources/saveCoverage.tmpl )
It might be possible to add an option to the plugin to stop it trying to parse/alter spec files and get coverage data working. 可能可以为插件添加一个选项,以阻止它尝试解析/更改spec文件并使覆盖数据正常工作。
Update: I've made some tweaks to grunt-protractor-coverage on my Github fork ( https://github.com/gazoakley/grunt-protractor-coverage ). 更新:我已经对我的Github分支上的grunt-protractor-coverage进行了一些调整( https://github.com/gazoakley/grunt-protractor-coverage )。 There's a pull request to get it back to actual grunt-protractor-coverage: https://github.com/r3b/grunt-protractor-coverage/pull/44
有拉动请求将其恢复到实际的grunt-protractor-coverage: https : //github.com/r3b/grunt-protractor-coverage/pull/44
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.