我有几个 Django 项目正在从事,我使用 Jenkins 进行持续集成。我已经安排并运行了一段时间,并且效果很好。
我希望能够生成自动测试覆盖率报告并让 Jenkins 处理它们。在我看来,django-jenkins是解决这个问题的方法,所以我安装了它并且coverage
.
这是我的相关部分settings.py
:
# Jenkins integration
INSTALLED_APPS += ('django_jenkins',)
JENKINS_TASKS = (
'django_jenkins.tasks.with_coverage',
'django_jenkins.tasks.run_pylint',
'django_jenkins.tasks.django_tests',
)
PROJECT_APPS = ['myapp']
现在,我可以运行了python manage.py jtest
,它按预期工作。但是,如果我运行python manage.py jenkins
,它会出错:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/matthew/Projects/blah/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/home/matthew/Projects/blah/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/matthew/Projects/blah/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 272, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/home/matthew/Projects/blah/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 76, in load_command_class
return module.Command()
File "/home/matthew/Projects/blah/venv/local/lib/python2.7/site-packages/django_jenkins/management/commands/__init__.py", line 61, in __init__
for module_name in self.get_task_list()]
File "/home/matthew/Projects/blah/venv/local/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
__import__(name)
ImportError: No module named django_tests
我使用标准的 DjangoTestCase
和LiveServerTestCase
类作为测试的基础。知道我在哪里出错了吗?该文档似乎暗示django_tests
已被删除,但我找不到任何关于您现在如何运行 Django 测试的迹象。
我正在使用 Django 1.6.2。