In a Django project, unit test are usually organized by app, with Django providing a facility to run all of the tests, the tests for a single app, a single test case, or a single test method.
Yet, I find that test cases in a single application usually belong to separate logical groups or clusters, and it would be often useful to be able to only run a single group of tests. Imagine, for example:
- I have several test cases covering each a different configuration of a single model, and I want to run all of them (and just them) while developing the model. (This is especially troublesome, because the cheap way to do that is to lump the test cases together, so now you have a single test case which you can easily run, but is a nightmare to read and maintain).
- I have a series of utility classes whose tests are extremely quick because they do not hit the database. I don't need to run model tests and view tests while refactoring these.
I searched around. But while it is relatively straightforward to split your tests in multiple files (see for example these two questions), there doesn't seem to be a straightforward way to run the test groups separately.
So, am I missing something? What is the secret sauce to group tests?