Is there an easy way to get a list of all tests in a Django project without running the tests themselves? I was hoping for something like ./manage.py test --list
.
If you are writing a reusable application you may want to use the Django test runner to run your own test suite and thus benefit from the Django testing infrastructure. A common practice is a tests directory next to the application code, with the following structure: runtests. py polls/ __init__. py models.
Order in which tests are executedAll TestCase subclasses are run first. Then, all other Django-based tests (test cases based on SimpleTestCase , including TransactionTestCase ) are run with no particular ordering guaranteed nor enforced among them. Then any other unittest.
Django provides a test framework with a small hierarchy of classes that build on the Python standard unittest library. Despite the name, this test framework is suitable for both unit and integration tests. The Django framework adds API methods and tools to help test web and Django-specific behavior.
If you're using the PyCharm IDE, you can run unittest or pytest by following these steps: In the Project tool window, select the tests directory. On the context menu, choose the run command for unittest . For example, choose Run 'Unittests in my Tests…'.
In my opinion, the more correct way is to use the actual tool for running tests. E.g. in case of nose:
./manage.py test <app> --verbosity 2 --collect-only
FYI, py.test also has --collectonly
option to print tests instead of executing.
Also see:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With