16

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)?

elad silver
  • 9,222
  • 4
  • 43
  • 67
Chiron
  • 20,081
  • 17
  • 81
  • 133
  • Did you read this? http://docs.djangoproject.com/en/1.2/topics/testing/#topics-testing What **specific** questions do you have after reading that? – S.Lott Aug 04 '10 at 22:47
  • 4
    FYI Cucumber can test Python code: http://wiki.github.com/aslakhellesoy/cucumber/python – Tim McNamara Aug 04 '10 at 22:55
  • I'm looking to know if Python has frameworks similar to RSpec and Cucumber, I know about unit testing in Python. @Tim, Thanks I didn't know about that. – Chiron Aug 04 '10 at 23:01
  • @El Gusto Try looking for "BDD Python", you'll find some good discussion here: http://stackoverflow.com/questions/231371/practicing-bdd-with-python – Tim McNamara Aug 04 '10 at 23:31
  • S.Lott: Didn't he specifically ask for BDD testing tools, and NOT the built in django testing stuff? – schmilblick Feb 11 '11 at 10:19

5 Answers5

19

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.

3

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.

elad silver
  • 9,222
  • 4
  • 43
  • 67
1

If you are referring to high level testing, and not unit testing, then you can still use Cucumber. Cucumber can be hooked up with Webrat and Mechanize, and you can use that setup to write stories to test your Django app. I have a setup like that. You can also hook up Cucumber with Watir, and do browser based testing.

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. 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.

OverClocked
  • 1,177
  • 1
  • 11
  • 19
1

I'm working with Robot Test Framework http://code.google.com/p/robotframework/. It is a generic test automation framework for acceptance testing and acceptance test-driven development (ATDD).

It's flexible and powerful and also allows BDD style in a similar way to lettuce/cucumber.

kgu
  • 11
  • 1
0

I had a good experience with TestBrowser, which allows you to write functional tests at a high level. See http://pypi.python.org/pypi/homophony for integration of TestBrowser with Django.

Gintautas Miliauskas
  • 7,744
  • 4
  • 32
  • 34