我应该使用 Protractor 还是 Karma 进行端到端测试? [英] Should I be using Protractor or Karma for my end-to-end testing?

查看:25
本文介绍了我应该使用 Protractor 还是 Karma 进行端到端测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我应该使用 Protractor 还是 Karma 进行端到端测试?

Should I be using Protractor or Karma for my end-to-end testing?

Angular-seed 使用 Protractor/Selenium WebDriver 进行 E2E,但 angular-phonecat 教程使用 karma.

Angular-seed is using Protractor/Selenium WebDriver for E2E but the angular-phonecat tutorial uses karma.

我读到我应该使用 Karma 进行单元测试,使用量角器进行 E2E,这看起来不错,但我想我会在这里询问其他开发人员的意见.

I read that I should use Karma for unit tests and Protractor for E2E, which seems fine but I thought I would ask on here to get other dev's opinions.

推荐答案

AngularJS 团队建议使用 Protractor,因为它将取代 Angular Scene runner:

The AngularJS team recommends using Protractor as it's going to replace angular scenario runner:

Angular Scenario Runner 处于维护模式 - 如果您要开始一个新的 Angular 项目,请考虑使用 Protractor.

Angular Scenario Runner is in maintenance mode - If you're starting a new Angular project, consider using Protractor.

引自 AngularJs 文档.

教程 angular-phonecat 是很久以前开发的(主要是 2011 年的),还没有更新使用一些 Angular 的新特性,比如量角器.

The tutorial angular-phonecat was developed a long time ago (in 2011 mainly) and has not yet been updated to use some Angular new features like Protractor.

编辑

Protractor 文档 - 常见问题中:

Karma 是一个很好的单元测试工具,Protractor 是为端到端或集成测试.这意味着对您的个人控制器、指令和服务的逻辑应该使用 Karma 运行.大型测试,其中您有一个正在运行的实例您的整个应用程序应该使用 Protractor 运行.量角器是旨在从用户的角度运行测试 - 如果您的测试可以写下来作为人类与您互动的说明应用程序,它应该是使用 Protractor 编写的端到端测试.

Why both Karma and Protractor? When do I use which?

Karma is a great tool for unit testing, and Protractor is intended for end to end or integration testing. This means that small tests for the logic of your individual controllers, directives, and services should be run using Karma. Big tests in which you have a running instance of your entire application should be run using Protractor. Protractor is intended to run tests from a user's point of view - if your test could be written down as instructions for a human interacting with your application, it should be an end to end test written with Protractor.

这是一篇很棒的博文 提供更多信息.

Here's a great blog post with more info.

这篇关于我应该使用 Protractor 还是 Karma 进行端到端测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆