3 Mayıs 2011, Salı
Çalışan uygulama testleri bir dizin varsa Django belirli bir test çalışması
Django belgeleri (**15) belirterek tek tek test çalışmaları çalıştırabilirsiniz diyor ki:
$ ./manage.py test animals.AnimalTestCase
Bu Django uygulamanızın tests.py bir dosya testlerinizi olduğunu varsayar. Eğer bu doğruysa, o zaman bu komut beklendiği gibi çalışır.
Testleri bir dizin Django uygulaması için benim sınavım var:
my_project/apps/my_app/
├── __init__.py
├── tests
│ ├── __init__.py
│ ├── field_tests.py
│ ├── storage_tests.py
├── urls.py
├── utils.py
└── views.py
tests/__init__.py
dosya süit() fonksiyonu:
import unittest
from my_project.apps.my_app.tests import field_tests, storage_tests
def suite():
tests_loader = unittest.TestLoader().loadTestsFromModule
test_suites = []
test_suites.append(tests_loader(field_tests))
test_suites.append(tests_loader(storage_tests))
return unittest.TestSuite(test_suites)
Yaptığım testler için:
$ ./manage.py test my_app
Bireysel bir test durumu belirlemek için çalışan bir özel durum oluşturur:
$ ./manage.py test my_app.tests.storage_tests.StorageTestCase
...
ValueError: Test label 'my_app.tests.storage_tests.StorageTestCase' should be of the form app.TestCase or app.TestCase.test_method
Özel durum iletisi dediğini yapmaya çalıştım:
$ ./manage.py test my_app.StorageTestCase
...
ValueError: Test label 'my_app.StorageTestCase' does not refer to a test
Nasıl benim testler birden fazla dosya olduğunda tek tek test durumu belirtmek musunuz?
CEVAP
3 Mayıs 2011, Salı
Çıkış 16**. Senin gibi çalıştırmak için test belirlemek için izin verir:
python manage.py test another.test:TestCase.test_method
Bunu Paylaş:
Nasıl bir dizi belirli bir değeri vars...
Çalışan tipik test dizin yapısı ile un...
Belirli bir test çalışması için test i...
Devre dışı Django 1.7 çalışan birim te...
Birim testleri çalışan Django Güney de...