Description
Discovered while testing #23935 (#73's solution) in pre-release, the Django unit test support is partially implemented via the CustomExecutionTestRunner
whose use is specified at test-time:
./manage.py --testrunner=django_test_runner.CustomExecutionTestRunner #...
This ignores any custom test runner the user may have set via the TEST_RUNNER
Django setting, which may result in tests not being executable through the Test Explorer, or cause a difference in behaviour between executed tests manually and through the Test Explorer.
As linked above, Django supports user-defined test runners, and imo there are many use cases for them beyond supporting non-unittest
testing frameworks. My particular use case is a test runner which overrides the setup_databases
and teardown_databases
methods to create and destroy unit test DBs with a Postgres admin user while still executing the tests with the default, lesser-permissioned DB user. This makes the testing more production-like as compared to the default Django experience. Without the custom test runner, the test execution fails as the default DB user (intentionally) does not have permission to create databases on its own.
Other simple uses cases may be adding additional CLI arguments to control the testing process, adding additional output to record attributes of the testing and its environment, or formatting the results for use in a secondary tool such as what xmlrunner/unittest-xml-reporting provides.