BDD周期 - 如何连接后端与前端 [英] BDD cycle - how to join backend with frontend

查看:272
本文介绍了BDD周期 - 如何连接后端与前端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何连接前端BDD(即茉莉花)和后端BDD(rspec,黄瓜)。
这两者如何相关并形成一个连贯的BDD周期?
这个循环的正确步骤是什么?

I'd like to know how you connect frontend BDD (i.e. Jasmine) with backend BDD (rspec, cucumber). How these two relate and form one cohesive BDD cycle? What would be the correct steps of this cycle?

推荐答案

要创建一个内聚BDD循环,外部的开发技术,然后采取伪造它直到你做它的方法,即使用模拟对象,直到你写具体的实现。

To create a cohesive BDD cycle you would use the "outside-in" development technique, and then take the approach of "faking it until you make it" i.e. using mock objects until you write concrete implementations.

以下黄瓜方案:

Given I am on the home screen
When I submit valid log-in credentials
Then I am navigated to the landing page

这将是最外面的测试。显然,当你运行这个时,每一步都会失败,因为没有什么被实现。

This would be the outermost test you have. Obviously when you'd run this each step would fail as nothing has been implemented.

现在你将恢复使用Jasmine创建前端BDD实现主屏幕。一旦你的Jasmine测试成功,这反过来会导致给定步骤通过。

Now you would revert to creating the front-end BDD using Jasmine to implement the home screen. Once your Jasmine tests succeed, this in turn would cause the "Given" step to pass.

接下来你会写更多的前端测试来实现登录功能,但在这个阶段你可以模拟对服务器的调用来实际验证用户(因此采取假它做出来的方法)。再次,通过嘲笑登录过程,您将能够快速开发登录屏幕并满足黄瓜测试。

Next you would write more front-end tests to implement the log-in functionality, but at this stage you may mock the call to the server to actually validate the user (hence taking the "fake it to make it" approach). Again, by mocking the log-in process you'll be able to rapidly develop the log-in screen and satisfy the cucumber test.

一旦你写了黄瓜测试并且你Jasmine测试通过,你将继续实现后端BDD开发关闭用户验证代码(即写具体代码,将验证登录到网站的用户)。

Once you have written the cucumber test and you Jasmine tests passing, you would then go on to implement the back-end BDD development off the user validation code (i.e. write the concrete code which will authenticate users logging into the site).

因此,您可以看到,这个Outside in开发方法允许您在后端和前端层使用BDD。

Hence you can see that this "Outside in" development approach allows you to use BDD at both the back-end and front-end layers.

关于此开发方法的其他有用文章如下:

Some other useful articles on this development approach are here:

  • http://rubylearning.com/blog/2010/10/05/outside-in-development/
  • http://blog.josephwilk.net/ruby/outside-in-development-with-cucumber-and-rspec.html
  • http://programmers.stackexchange.com/a/166437

这篇关于BDD周期 - 如何连接后端与前端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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