Ivailo Karamanolev
Ivailo Karamanolev

Reputation: 823

Django testing: separate unit and integration tests on Travis CI

I have a Django project that already has some unit tests using the standard Django testing framework. That works well. Now I want to set up integration tests with Travis CI, but I'm hitting several blockers:

  1. Django docs don't say how to separate self-contained ./manage.py test unit tests from the integration tests, that require external services to be set up. I want to only run unit tests on my dev machine and Travis CI to run both unit and integration tests. How do I separate these?
  2. I have the database on Travis CI filled with some initial data populated during the setup. I want integration tests to run with that, but unit tests to continue using a temporary test-only DB. How do I do that?

Upvotes: 2

Views: 1163

Answers (1)

FlogFR
FlogFR

Reputation: 779

1- You can run any test you want from the manage.py test command. So you can create a file unit_test.py and run only the tests inside this file.

manage.py test --help

2- You don't want to do that. Run test against a production/semi-production database is a shame. You need to create fixtures for every tests, and run your tests against a temporary database. If you really want to know the answer, it has already been answered here

Upvotes: 1

Related Questions