Angular 端到端测试实习生或量角器

Intern or Protractor for Angular E2E Testing

除了能够利用 Angular 定位器方法之外,为什么要使用 Protractor 测试框架而不是 Intern 测试框架来进行 Angular 端到端测试?

除了 AngularJS 特定定位器,如 by.modelby.repeaterprotractor 知道页面何时完全加载、何时 Angular 安顿下来以及就绪 - 它使测试 运行 自然地进行,通常不需要使用显式等待或在测试代码中引入人为延迟。换句话说,它始终与 Angular:

同步工作

You no longer need to add waits and sleeps to your test. Protractor can automatically execute the next step in your test the moment the webpage finishes pending tasks, so you don’t have to worry about waiting for your test and webpage to sync.

此外,protractor还有一个非常方便和丰富的API. It's not only wrapping WebdriverJS, but also extending it introducing new features on top. For instance, there are multiple functional programming functions available on an array of web elements, like map() or reduce(). I also like the way it allows to work with "repeaters" through rows and columns. Additionally, there is a nice Plugin API和一组内置插件,如accessibilitytimeline

作为附带奖励,有一个 protractor-perf 包使用 protractorbrowser-perf 进行性能回归测试。您甚至可以使用现有的 e2e 测试作为性能测试的基础,将所需的测试代码块包装到 perfRunner.start()perfRunner.stop() 中。

Protractor 的一大优点是它通过绑定到 AngularJS 元素来检查元素何时完成加载来解决异步问题。它还具有更易于阅读的语法(如果您来自 ruby 背景)和更多实用教程。 Intern 和 Protractor 在这个博客中有更详细的比较 post here.