Skip to content

Commit

Permalink
Last-minute panic tweaks.
Browse files Browse the repository at this point in the history
  • Loading branch information
carljm committed Mar 10, 2012
1 parent 33dceb0 commit d2e1390
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 15 deletions.
10 changes: 7 additions & 3 deletions levels/10_intro.md
Expand Up @@ -9,7 +9,7 @@
.notes Go see the video of Gary's "Fast test, slow test" talk.


<!SLIDE>
<!SLIDE incremental>

# Unit tests #

Expand All @@ -20,12 +20,16 @@

* Help you structure your code better.

<!SLIDE>
<!SLIDE incremental>

# Integration tests #

* Test that the whole integrated system works; catch regressions.

* Slow (just write a few, test the edge cases with unit tests).
* Slow.

* Less useful failures.

* Write fewer.

.notes Summary: both are useful, write more unit tests.
27 changes: 26 additions & 1 deletion models/10_dbsetup.md
Expand Up @@ -3,9 +3,34 @@
## The database makes your tests slow. ##

* Try to write tests that don't hit it at all.
* Separate db-independent model-layer functionality from db-dependent
functionality.
* But you'll still have a lot of tests that do.
* Mocking the database usually isn't worth it.

.notes The DB is pretty core to most web apps; mocking it makes your tests fast, but I don't think it's worth it.
<!SLIDE>

@@@ python
class Thing(models.Model):
def frobnicate(self):
"""Frobnicate and save the thing."""
# ... do something complicated
self.save()


<!SLIDE>

@@@ python
def frobnicate_thing(thing):
# ... do something complicated
return thing


class Thing(models.Model):
def frobnicate(self):
"""Frobnicate and save the thing."""
frobnicate_thing(self)
self.save()

<!SLIDE incremental>

Expand Down
8 changes: 0 additions & 8 deletions title/10_plan.md

This file was deleted.

2 changes: 2 additions & 0 deletions views/50_guideline.md
Expand Up @@ -4,6 +4,8 @@

* Write system tests for your views.

* Write Selenium tests for Ajax, other JS/server interactions.

* Write unit tests for everything else (not strict).

* Test each case (code branch) where it occurs.
Expand Down
2 changes: 1 addition & 1 deletion whichtests/30_problem.md
@@ -1,6 +1,6 @@
<!SLIDE incremental>

# Django's test runner #
# Django's test discovery #

* Wastes my time with tests I don't care about.
* Requires app tests to be in a single module (resulting in boilerplate
Expand Down
4 changes: 2 additions & 2 deletions whichtests/40_solution.md
Expand Up @@ -3,7 +3,7 @@
# It's easy to change. #

* unittest2 discovery
* `TEST_RUNNER`
* `TEST_RUNNER` setting

.notes The hipsters like nose or py.test, but unittest2 gets the job done.

Expand Down Expand Up @@ -48,7 +48,7 @@

# \o/ #

* Discovers tests wherever you put them.
* Discovers tests wherever you want them.
* Doesn't run tests from external apps by default.
* Flexible specification of specific tests to run: Python dotted path to test
module, not Django app label.
Expand Down

0 comments on commit d2e1390

Please sign in to comment.