简体   繁体   English

我怎样才能用黄瓜覆盖量角器

[英]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.

相关问题 如何从量角器[3.0.0]和黄瓜最新版本获得cucumber-test.json - How to get cucumber-test.json from protractor [3.0.0] and cucumber latest version 如何使用量角器获取当前网址? - how can I get the current url using protractor? 如何使用量角器在dropdowlist中随机获取元素? - How can I get an element randomly in a dropdowlist using protractor? 如何从带有量角器的元素中获取子项数量? - How can I get the number of children from an element with protractor? 我如何从一个元素中获得不同的孩子 - Protractor - How can i get different childs from one element - Protractor 如何在 protractor 中获取特定路径中的 multiple.dat 文件 - How can i get the multiple .dat files in particular path in protractor 如何在量角器黄瓜框架中使用断点进行调试 - how to Debug using breakpoint in protractor cucumber framework E/launcher - 无效的会话 ID。 运行黄瓜量角器框架时出现错误。 我如何解决它并运行多个功能文件? - E/launcher - invalid session id. Getting the error when running cucumber protractor framework. How can i resolve it and run multiple feature files? 量角器:如何拉伸和替换元素? - Protractor: How I can stretching and replasing elements? 我怎么能有mocha记者的量角器? - How can I have mocha reporter for protractor?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM