DHH单元测试:RSpec确实不必要复杂? [英] DHH on Unit Testing : Is RSpec indeed needlessly complicated?

查看:162
本文介绍了DHH单元测试:RSpec确实不必要复杂?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我碰巧是Ruby Inside的订阅者,因为我对Rails特别感兴趣。昨天,Rails的创建者,David Heinemeier Hansson,几乎说他只是使用测试/单元。我会明白,因为它是Rails内部的,但他似乎给了一个强烈的意见。他认为RSpec和Cucumber是不必要的复杂。

I happen to be a subscriber of Ruby Inside, since I'm particularly interested in Rails. Yesterday, the creator of Rails, David Heinemeier Hansson, pretty much said that he's just using test/unit. I would understand that, since it's Rails internal, but he seems to have given a strong opinion. He believes that RSpec and Cucumber are needlessly complicated.

我通常不会注意,但这取决于谁说什么。我尊重汉森很多,他的意见让我思考。当我开始与Rails,我从来没有真正考虑测试/单位。只是RSpec和Cucumber。

I would normally not pay much attention, but it depends on who says something. I respect Hansson a lot and his opinion got me thinking. When I started with Rails, I never really looked into test/unit. Just RSpec and Cucumber.

这就是为什么我想要你的洞察力。你认为RSpec确实很复杂,没有太多的附加值?写测试/单元需要更少的时间和精力吗?

And that is why I want your insight. Do you think that RSpec is indeed complicated for not much added value? Does writing test/unit take less time and effort?

推荐答案

我的建议是使用Shoulda(extends Test :: Unit)或RSpec with Capybara,and -no- Cucumber 。

My recommendation would be to use either Shoulda (extends Test::Unit) or RSpec with Capybara, and -no- Cucumber.

我认为使用RSpec或Shoulda嵌套上下文是绝对值得的。 RSpec肯定是重量级的(也许超重),而且我在这个原因的栅栏。

I think that the use of either RSpec or Shoulda for nested contexts is definitely worth doing. RSpec is definitely heavy-weight (perhaps overweight) though, and I'm on the fence with it for that reason.

Cucumber,我终于明白了,是waaay更麻烦比它通常值得。你可以使用简单的集成测试和Capybara更简单,更强大地完成你所需要的。记住 - Capybara!= Cucumber,Capybara是非常有能力的。

Cucumber, I've finally come to understand, is waaay more cumbersome than it's usually worth. You can accomplish what you need more simply and robustly with plain ol' integration tests and Capybara. Remember -- Capybara != Cucumber, and Capybara is quite capable all on its own.

Shoulda很好,因为它只是简单地增加了标准的Test :: Unit框架,因此比RSpec轻得多(技术上,每个解决不同的问题集,但它们都提供嵌套上下文能力)。 RSpec具有使断言更自然地读取的优点,并且在许多情况下也产生更有帮助的失败消息,而不需要在断言上书写消息参数。

Shoulda is nice, because it simply adds conveniences to the standard Test::Unit framework, and is therefore much lighter-weight than RSpec (technically, each solves a different set of problems, but they both provide nested-context capabilities). RSpec has the advantage of making assertions read more naturally, and also generating more helpful failure messages in many cases, without the need for writing message arguments on the assertions.

记住Cucumber实际上不需要RSpec,所以如果你想继续使用Cucumber,你可以使用Test :: Unit。选择比比皆是。

Also, remember that Cucumber does not actually require RSpec, so if you want to keep using Cucumber, you can do that with just Test::Unit. Choices abound.

这篇关于DHH单元测试:RSpec确实不必要复杂?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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