On Jun 6, 2006, at 6:42 PM, Todd O'Bryan wrote:

Does anybody have a best practice (or not-too-annoying practice) for  
testing?

I think I'll use Selenium to test my site, but how should I change to  
a test database, populate the test database, etc.?



If you want to test your model relationships, I find that the tests you do in the python shell (creating objects and running queries) are great because they can be quickly cut and pasted into doctests, preserving your failed model explorations as future tests.

For unit testing, you don't really need a database. You can always mock the database calls, because you're not testing the data or the database (if postgres is up, the database is working), you're testing your code's behavior to the data. When I first starting using testing methods, I was obsessed with having perfect test data, but quickly realized what I really want is perfect code. I don't really mean perfect, but the code should always be better than the data.

When I write tests I try not to test django's code, it already has a test suite (hey, if a bug in django makes my code work, how or why should I care? Of course, when they fix the bug and my code breaks, well then I can write a test for it).

twill is a great tool for automating web interaction. Twill works from a script (or command line). One good reference source is the test folder in django itself. And Greenpeace's custard/melt django project has an extensive test suite you can learn from (they use selenium as well).

And for reference, chromatic's "Perl Testing: A Developer's Notebook" is a very good tutorial on testing methods, with a Perl slant.

Info on a mock library for python:
sourceforge.net/projects/python-mock

Here's some good testing info using python:

Don

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to