Speed up TDD with Plone
TDD w/o extensive mock-them-objects work is quite slow in Plone due its startup time. Enter roradrunner.
What?
When using TDD (Test Driven Development), one needs to have a fast write test - run test - write code - test - repeat cycle. Unfortunately, Plone's integration tests need lots of time to start up.
Roadrunner
Roadrunner (PyPi page) is a test runner, which preloads Zope and Plone and then allows to run the tests multiple times, waiting for a promt while doing so.
This is great, because the majority of time is used in the startup, which is now done _once_. Tests usually run in seconds.
Wow! How do I use it?
First, make sure your tests use a deferred startup as explained in the documentation here:
http://plone.org/documentation/tutorial/testing/writing-a-plonetestcase-unit-integration-test
Then, add a buildout part to your development buildout like so:
[roadrunner] recipe = roadrunner:plone packages-under-test = inquant.tellurium
That's it! Re-run the buildout, then start the test using:
$ bin/roadrunner -s inquant.tellurium
You'll see something like:
Preloading Plone ... Installing CMFCore ... done (12.046s) Installing CMFDefault ... done (8.583s) Installing CMFCalendar ... done (0.673s) Installing CMFTopic ... done (0.607s) Installing DCWorkflow ... done (1.157s) Installing CMFActionIcons ... done (0.368s) Installing CMFQuickInstallerTool ... done (0.844s) Installing CMFFormController ... done (2.002s) Installing GroupUserFolder ... done (2.139s) Installing ZCTextIndex ... done (0.441s) Installing CMFPlone ... done (19.572s) Installing Archetypes ... done (0.415s) Installing ATContentTypes ... done (0.107s) Installing ATReferenceBrowserWidget ... done (0.048s) Installing CMFDynamicViewFTI ... done (0.012s) Installing ExternalEditor ... done (0.060s) Installing ExtendedPathIndex ... done (0.084s) Installing ResourceRegistries ... done (0.060s) Installing SecureMailHost ... done (0.043s) Installing CMFPlacefulWorkflow ... done (0.359s) Installing PasswordResetTool ... done (0.190s) Installing PluggableAuthService ... done (0.283s) Installing PluginRegistry ... done (0.029s) Installing PlonePAS ... done (0.084s) Installing kupu ... done (2.365s) Installing CMFEditions ... done (0.129s) Installing CMFDiffTool ... done (0.100s) Installing PloneLanguageTool ... done (0.054s) Set up Products.PloneTestCase.layer.ZCML in 26.367 seconds. Set up Products.PloneTestCase.layer.PloneSite in 14.556 seconds. Preloading took: 107.685 seconds. Running tests at level 1 Running Products.PloneTestCase.layer.PloneSite tests: Installing inquant.tellurium ... NOT FOUND Set up Products.PloneTestCase.layer.PloneSite in 0.860 seconds. Running: .......................... Ran 26 tests with 1 failures and 0 errors in 7.948 seconds. Tearing down left over layers: Tear down Products.PloneTestCase.layer.PloneSite in 0.639 seconds. Tear down Products.PloneTestCase.layer.ZCML in 0.007 seconds. Testrunner took: 10.376 seconds. rr> _
The rr> is the roadrunner command line. If you hit enter now, it will execute the same test again, without doing the startup, which took 107 seconds in this example.
The command prompt takes all the arguments like a normal testrunner, so you can run other tests, too. Basically you do not need to exit the loop ever.
Cool, eh?

