Reputation: 4245
The convention for creating tests in django is to place tests in modules named tests_*.py
and to run then as python manage.py test
.
This will run all tests defined tests in all modules named tests.
The challenge I have come across is that integration tests may require significant setup of resources e.g. connection to external services. I would imagine mocking out those services in integration tests would cause integration tests to loose their meaning.
I am inquiring therefore of the best practice in running only unit tests and only run integration tests when unit tests are running properly.
The only way I can imagine is to place integration tests
in files named with a different pattern such as integration_*.py
and then use the pattern parameter when running integration tests as specified by the django documentation
Like this python manage.py test --pattern="integration_*"
.
In this way when python manage.py test
is called integration tests will be ignored.
Does anyone have a suggestion or recommendation.
Upvotes: 4
Views: 981
Reputation: 3378
You can use Tagging test to handle this. Try to tag your test by a name then:
./manage.py test --tag=integration
Upvotes: 9