角量角器端到端测试 [英] Angular Protractor e2e Testing

查看:172
本文介绍了角量角器端到端测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写使用量角器我的角度应用的终端到终端的测试。我可以模拟httpBackend单元测试,但我想实际调用服务器,并获得JSON响应返回并重新编写测试返回的数据。结果
我已阅读计算器很多,但不明白这是如何实现的。

I am writing an end-to-end test using Protractor for my Angular application. I can mock httpBackend for unit test but I want to actually call the server and get the JSON response back and write tests again the data returned.
I have read a lot on stackoverflow but can not understand how this is done.

我使用$ HTTP?我如何注入到我的茉莉花测试?我如何得到响应JSON回到我的茉莉花考验?

Do I use $http? How do I inject it into my Jasmine tests? How do I get the response JSON back into my Jasmine test?

任何帮助或资源的链接与这样的说明会有所帮助。

any help or links to resources with instructions on doing this will be helpful.

我又不想嘲笑服务器,我想打服务器,并获得JSON回来。

Again I do NOT want to mock to server, I want to hit the server and get the JSON back.

谢谢!

推荐答案

我通过这个自己目前的工作。简短的回答,我认为是你设置你的应用程序完全一样,如果你是自己手工测试它 - 所以量角器真的只是一个机器人的用户,它没有(当然,几乎没有)访问你的应用程序的内部结构。

I'm working through this myself at the moment. The short answer I think is that you set up your application exactly the same as if you were manually testing it yourself - so Protractor is really just a robot user, it has no (well, almost no) access to the internals of your application.

所以,如果你的应用需要一个Web服务器(和大多数人),那么你就启动了Web服务器,然后让量角器通过浏览器连接到您的应用程序并执行它。

So, if your application needs a web server (and most do), then you start up that web server, then have protractor connect to your application via the browser and exercise it.

有关我的情况,我的目标使用咕噜叫,做基本的数据库设置它开始运行我的量角器端到端测试前的任务 - 这应该给我一个已知的数据库状态

For my case, I'm aiming to use grunt to call a task that does basic database setup before it starts running my protractor e2e tests - this should give me a known database state.

有关这方面的一个例子,我已经写了使用带有AngularJS轨道4的教程,使用量角器进行端到端测试部分不轨特定的,可能是有用的:
HTTP://technpol.wordpress.com / 2013年/ 11/16/5-端至端测试/

For an example of this, I've been writing a tutorial for using Rails 4 with AngularJS, the section on using protractor for e2e testing is not rails-specific and might be useful: http://technpol.wordpress.com/2013/11/16/5-end-to-end-testing/

这篇关于角量角器端到端测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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