Running Subsets of Review Board Tests

Have you been writing tests for Review Board?  If so, you’ll want to read this.  This is copy-paste from a super-useful e-mail that David Trowbridge sent out to the UCOSP mailing list:

Mark in our UCOSP group this semester had a question, and I think the answer would be handy to many of you who want to use our test suite. Specifically, because the suite takes several minutes to run, is there a way to run a subset of the tests?

We use a test runner called “nose”. Presumably when you were running through the initial development instructions, you installed this package. It supports a lot of special arguments for limiting test cases and other functionality, but any arguments you want to pass to it have to come after a “–” argument to manage.py test.

To run only the tests in a specific module:

./reviewboard/manage.py test -- reviewboard.scmtools.tests

To run the tests in a specific class:

./reviewboard/manage.py test -- reviewboard.scmtools.tests:GitTests

And finally, if you want to run only a specific test case:

./reviewboard/manage.py test -- reviewboard.scmtools.tests:GitTests.testFilemodeWithFollowingDiff

Some other flags which come in handy are -x, –pdb and –pdb-failures.

This will stop the test runner after the first encountered failure.

./reviewboard/manage.py test -- -x

This will drop into pdb (the python debugger shell) when an error occurs. In django test parlance, errors are problems that aren’t “test failures” per se — things like uncaught exceptions.

./reviewboard/manage.py test -- --pdb

Similarly, –pdb-failures will drop into pdb when a test case assertion fails.

Hope this help cut down your turnaround time!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s