简体   繁体   English

Django的BDD测试工具是否与Rails的测试工具相当?

[英]Does Django have BDD testing tools comparable to Rails' testing tools?

Ruby/Rails enjoy some really nice and powerful Behavior Driven Design/Development testing frameworks like Cucumber and RSpec . Ruby / Rails享受一些非常好的和强大的行为驱动设计/开发测试框架,如CucumberRSpec

Does Python/Django enjoy the same thing (I'm not talking about simple unit testing like PyUnit)? Python / Django是否喜欢同样的东西(我不是在谈论像PyUnit那样简单的单元测试)?

There is a new tools called Lettuce that promises to be a Pythonic version of Cucumber. 有一种名为Lettuce的新工具,有望成为Cucumber的Pythonic版本。 It is starting with Django integration. 它从Django集成开始。 That plus the existing testing tools in Django make it pretty good for unit testing. 加上Django中现有的测试工具使其非常适合单元测试。

There's also a tool called Windmill that provides a solid browser-based testing tool for building GUI tests. 还有一个名为Windmill的工具,它提供了一个基于浏览器的可靠测试工具,用于构建GUI测试。 Couple that with a tool like Lettuce for writing acceptance tests and the straight unittest and nosetests and I'd say you're set. 夫妇,与编写验收测试和直像生菜的工具单元测试nosetests和我说你设置。

The thing to remember, there's a slightly different culture between Ruby and Python. 要记住的是,Ruby和Python之间的文化略有不同。 Ruby has a preference for tests above all else. Ruby优先考虑测试。 In Python it's documentation. 在Python中它是文档。 As such, there's not a million and one testing frameworks in Python, just a few really solid ones with the occasional outlier (like Lettuce). 因此,Python中没有一百万个测试框架,只有一些非常可靠的,偶尔有异常值(如生菜)。

Hope this helps. 希望这可以帮助。

in case someone is still visiting here, Aloe , is a lettuce upgrade and has integration for django 1.8. 如果有人还在这里, Aloe ,是一个生菜升级,并与django 1.8集成。 I'm starting to use it now. 我现在开始使用它。

If you are referring to high level testing, and not unit testing, then you can still use Cucumber. 如果您指的是高级测试,而不是单元测试,那么您仍然可以使用Cucumber。 Cucumber can be hooked up with Webrat and Mechanize, and you can use that setup to write stories to test your Django app. 黄瓜可以与Webrat和Mechanize连接,您可以使用该设置编写故事来测试您的Django应用程序。 I have a setup like that. 我有这样的设置。 You can also hook up Cucumber with Watir, and do browser based testing. 您还可以将Cucumber与Watir连接起来,并进行基于浏览器的测试。

There isn't something like FactoryGirl to auto generate data for your model, but you can use Django fixtures to create initial data for your model, and only have the fixtures installed when you are in testing mode. 没有像FactoryGirl那样为您的模型自动生成数据,但您可以使用Django灯具为您的模型创建初始数据,并且只有在您处于测试模式时才安装灯具。 Then you can start a test, and have some data to test with. 然后你可以开始测试,并有一些数据要测试。

With those things, you can setup a fairly comprehensive high level test suite. 有了这些东西,您可以设置一个相当全面的高级测试套件。 Then you can use Django unit test to do low level testing. 然后你可以使用Django单元测试来进行低级测试。

I'm working with Robot Test Framework http://code.google.com/p/robotframework/ . 我正在使用机器人测试框架http://code.google.com/p/robotframework/ It is a generic test automation framework for acceptance testing and acceptance test-driven development (ATDD). 它是验收测试和验收测试驱动开发(ATDD)的通用测试自动化框架。

It's flexible and powerful and also allows BDD style in a similar way to lettuce/cucumber. 它灵活而强大,并且允许BDD样式与生菜/黄瓜类似。

I had a good experience with TestBrowser, which allows you to write functional tests at a high level. 我对TestBrowser有很好的体验,它允许你在高级别编写功能测试。 See http://pypi.python.org/pypi/homophony for integration of TestBrowser with Django. 有关将TestBrowser与Django集成的信息,请参见http://pypi.python.org/pypi/homophony

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM