« Automating tests in Django | Easily packaging and distributing Django apps with setuptools and easy_install »
Okay, Well I have been hacking away at django-testmaker for the last couple of days based on some ideas from the community. It has gotten a lot better, so here is another blog post showing what's new.
First let me just say how awesome the Django community is, and I am really beginning to understand (and appreciate!) the open source ethos. I would never have gotten this code this good in 3 days without releasing it to the public. Thanks everyone for looking over it and giving feedback!
Testmaker got a management command! Now you don't have to worry about messing with your middlware and having to take out the testmaker stuff when in production. You simply add testmaker to your INSTALLED_APPS and away you go.
Here is another video of it in action:
Step 1: Add testmaker to your INSTALLED_APPS settings.
Step 2:
In the directory above the APP that you want to test, run
./manage.py testmaker -a APP
This should tell you where it is logging to, and where the fixture files are going. It should only make fixtures once, so if you change something in your database, you need to go ahead and delete the old fixtures file and it will re-create a new one. It also has 3rd grade file-naming heuristics built in. So if a tests directory exists in your project, it will log to APP-testmaker.py, if there is no tests.py in your APP directory, it will put itself in that file. If you have an existing tests.py file, it will make a tests-testmaker.py file. You will then need to take the contents of this file and integrate it into your normal tests. In a future version if it encounters a tests.py, it may make a tests directory and put both files inside of that, but I don't know if that is a good idea.
Step 3:
Once you have reconciled the above changes (only necessary if you previously had a tests.py file in your APP directory)
./manage.py test APP
Then you have awesome base-line tests for your app.
In my release post I had some comments about the usefulness of these tests. I think that it is a very useful thing if you have an existing body of code with no tests. This will give you a non-trivial base to then at least have tests for your code.
Testing all of your views will also presumably alert you to errors introduced in your models and URLConf files as well. Having dedicated tests to testing models is still better and a good idea, but this code will at least give you a good starting point.
Being able to automate a base-line level of tests for an app will hopefully make people more inclined to include these basic tests in their apps, and everyone knows tests are better than no tests.
There are also a few problems that I've had with the output. It appears Satchmo is hijacking the logging module on output? If anyone knows a good way to fix this, please let me know.
Also, the POSTing stuff hasn't been well tested, so there might be a few bugs in that, it is pretty rudimentary.
Posted at 3:21 p.m. on July 26, 2008
Comments: 4
Tags: django , screencast , testing , testmaker
Automating tests in Django
The value of conventions, aka testmaker for template tags.
Mocking an External Web Service in Python
Welcome to the home of Eric Holscher on the web. I talk about software development, mostly in the realm of Django. I am interested in the real time web, testing, mobile apps, and other things.
Why Read the Docs matters
1 week, 5 days ago (Comments: 7)
Read the Docs Update
9 months, 4 weeks ago (Comments: 2)
Using Reviewboard with Git
1 year ago (Comments: 0)
Read the Docs Updates
1 year ago (Comments: 1)
Handling Django Settings Files
1 year ago (Comments: 12)
Required Reading
1 year, 2 months ago (Comments: 0)
Using Haystack to index non-database content
1 year, 2 months ago (Comments: 4)
Correct commands to check out and update VCS repos
1 year, 2 months ago (Comments: 0)
Site upgrades
1 year, 2 months ago (Comments: 0)
Building a Django App Server with Chef: Part 4
1 year, 2 months ago (Comments: 1)
Setting up Django and mod_wsgi
Building a Django App Server with Chef: Part 1
Screencast: Django Command Extensions
Big list of Django tips (and some python tips too)
Handling Django Settings Files
Lessons Learned From The Dash: Easy Django Deployment
Large Problems in Django, Mostly Solved: Delayed Execution
Building a Django App Server with Chef: Part 2


Comments
1 says...
I've got a workaround for the satchmo problem I came up against if you want it?
Posted at 11:06 a.m. on July 27, 2008
2 says...
@David, sure. I don't know the logging module too well yet, so I'd love to hear how to use it better (or not use it at all :)
Posted at 3:39 p.m. on July 27, 2008
3 says...
@Eric: What I did wasn't particularly clever, but it seemed to work with my Satchmo setup:
http://dpaste.com/hold/67837/
Basically, all I'm doing is using debug() instead of info()
Posted at 8:18 a.m. on July 28, 2008
4 Jay says...
I saw your 1st video on testmaker and think it's a great idea! (this one even more affirms that).
It's tangential but I was wondering what you use for making your screencasts (I particularly liked the popup of the keystrokes).
My new Macbook is in the mail (my first ever) so I'm trying to learn all the Apple stuff I've been missing for so long ;)
Posted at 4:36 p.m. on December 3, 2008