mardi 5 juillet 2016

How to ensure fixture getting loaded only once for all testcases in django 1.9?

I'm working on test cases for my project where I've to use fixture for data. The fixture is quite big (around 20 MB) for entire project. Since the project involves multiple apps so I want that the fixture gets loaded only once when I run tests. Specifying fixtures on each test cases as well as using keepdb flag is not working great and it takes alot of time to all tests. Can you please suggest a good workaround for the same so I can speed it up. I also followed this post but its not working with django 1.9.

Added sample tests App1/tests.py

from django.test import TestCase
class App1View1TestCase(TestCase):
    fixtures = [
        'fixtures/app_fixture.json',
    ]
class App1View2TestCase(TestCase):
    fixtures = [
        'fixtures/app_fixture.json',
    ]
class App1View3TestCase(TestCase):
    fixtures = [
        'fixtures/app_fixture.json',
    ]

App2/tests.py

from django.test import TestCase
class App2View1TestCase(TestCase):
    fixtures = [
        'fixtures/app_fixture.json',
    ]
class App2View2TestCase(TestCase):
    fixtures = [
        'fixtures/app_fixture.json',
    ]
class App2View3TestCase(TestCase):
    fixtures = [
        'fixtures/app_fixture.json',
    ]

Each testcase has more than 5 tests.

Aucun commentaire:

Enregistrer un commentaire