

A rewrite of the Django tutorial with Test Driven Development - rbanffy
https://github.com/hjwp/Test-Driven-Django-Tutorial

======
phzbOx
This is cute, but not really realist. I.e. The test written before configuring
the Django Admin.. how can you know what links you have to click if you don't
see the page?

~~~
condiment
I agree that this example is a little confusing. The author is making
assumptions about the behavior of the Django admin site based on either his
previous experience using it, or the Django documentation. In practice it
could be extremely difficult to write advance tests for third-party libraries,
although I admit I don't have much experience doing this.

Normally I'd expect devs to write tests based on formal specifications of the
desired program output (ha! more like a loose mental model). In these cases,
all of the eventual behavior of the tested module will be controlled by code
that the dev themselves wrote, which makes a much more compelling argument for
TDD, but is also more difficult to convey in a made-for-newbies tutorial like
this one.

------
LeafStorm
The testing code looks horribly un-Pythonic to me, and I really don't think
one should have to download a Java JAR to test a Python framework.

~~~
amccloud
What doesn't look pythonic to you? Looks like he uses unittest for testing
python and Selenium (java jar, certainly not required) for testing the
frontend (html/js/rendering) in browser.

~~~
LeafStorm
`javaStyleMethodNames` and using `self.assertSomething`. Despite its inclusion
in the standard library, `unittest` is not a very Pythonic library (it comes
from the days when most of the advanced portions of the stdlib was ported over
from Java). Nose is slightly better and Attest[1] is the only one that I would
really call "Pythonic."

[1]: <http://packages.python.org/Attest/>

------
jeff_5nines
Thank you. I've only worked on small projects and never truly forced myself to
embrace tdd. I've always wondered why, if the Django core guys are so
supportive of tdd, why it was not represented more in the original tutorial. I
don't mean any disrespect, the tutorial is the best I've ever seen for such a
framework and I realize they can't spoon feed us everything.

~~~
andybak
I don't recall hearing the Django guys espousing TDD. Testing - yes - but not
especially a 'Tests firsts' approach.

I could be wrong but I wonder if you're conflating writing tests (everyone
should do it) with TDD (a little more controversial)

------
bryanh
In my opinion, this is one thing that the Rails folks have definitely got
right. Testing is very important if your project is going to be of any size or
if multiple people are working on it.

Testing with Django should probably be more transparent and definitely
encouraged for beginners, and this is a great start!

~~~
getsat
Not just Rails, Ruby projects in general. Most have awesome test coverage.

------
barnaby
THANK YOU for posting this! I always had to figure out how to test my code
AFTER the fact when reading Django documentation. This makes it much easier to
write good code. Thanks!

------
hugs
This is awesome! I think more tutorials should be written this way. ;-)

------
pge
For other python web developers, what front end test tools do you other than
selenium? Anything better out there?

~~~
casenelson
Check out Sikuli, it does pattern matching on images with a bit of OCR thrown
in. It has its own quirks and isn't nearly as mature as Selenium but is neat
because it doesn't care at all about the underlying layout of a page.

<http://sikuli.org/>

