Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

Does Python/Django enjoy the same thing (I'm not talking about simple unit testing like PyUnit)?

like image 955
Chiron Avatar asked Aug 04 '10 22:08

Chiron


People also ask

What test framework does Django use?

The preferred way to write tests in Django is using the unittest module built-in to the Python standard library. This is covered in detail in the Writing and running tests document. You can also use any other Python test framework; Django provides an API and tools for that kind of integration.

Is Django used for testing?

Django provides a test framework with a small hierarchy of classes that build on the Python standard unittest library. Despite the name, this test framework is suitable for both unit and integration tests. The Django framework adds API methods and tools to help test web and Django-specific behavior.

What is automated testing in Django?

Automated Testing is a widely used tool that uses a collection of predefined test cases. Learn how Django and Selenium to ensure a bug free system. Table of contents.

Should I test Django models?

If the code in question is built into Django, don't test it. Examples like the fields on a Model or testing how the built-in template. Node renders included tags. If your model has custom methods, you should test that, usually with unit tests.


2 Answers

There is a new tools called Lettuce that promises to be a Pythonic version of Cucumber. It is starting with Django integration. That plus the existing testing tools in Django make it pretty good for unit testing.

There's also a tool called Windmill that provides a solid browser-based testing tool for building GUI tests. Couple that with a tool like Lettuce for writing acceptance tests and the straight unittest and nosetests and I'd say you're set.

The thing to remember, there's a slightly different culture between Ruby and Python. Ruby has a preference for tests above all else. In Python it's documentation. 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).

Hope this helps.

like image 72
Travis Swicegood Avatar answered Oct 06 '22 22:10

Travis Swicegood


in case someone is still visiting here, Aloe, is a lettuce upgrade and has integration for django 1.8. I'm starting to use it now.

like image 25
elad silver Avatar answered Oct 06 '22 21:10

elad silver