1

我正在使用 Django 单元测试框架来测试我的应用程序。当我执行所有测试用例时,我会得到关于成功运行的测试用例的非常简短的信息。

----------------------------------------------------------------------
Ran 252 tests in 8.221s

OK

这是非常少的信息。我想了解有关每个测试用例的更多信息,

例如

每个测试用例执行所花费的时间。

成功完成每个测试模块。等等等等

我们是否有任何调试(或任何其他参数)参数可以启用有关已执行测试用例的扩展信息?

注意:- 使用详细参数不能满足我的需要

4

2 回答 2

0

每个 django 命令都有一个--help选项,如果你输入:

python manage.py test --help您将看到该命令的所有可用选项test

Options:
  -v VERBOSITY, --verbosity=VERBOSITY
                        Verbosity level; 0=minimal output, 1=normal output,
                        2=verbose output, 3=very verbose output
  --settings=SETTINGS   The Python path to a settings module, e.g.
                        "myproject.settings.main". If this isn't provided, the
                        DJANGO_SETTINGS_MODULE environment variable will be
                        used.
  --pythonpath=PYTHONPATH
                        A directory to add to the Python path, e.g.
                        "/home/djangoprojects/myproject".
  --traceback           Raise on exception
  --noinput             Tells Django to NOT prompt the user for input of any
                        kind.
  --failfast            Tells Django to stop running the test suite after
                        first failed test.
  --testrunner=TESTRUNNER
                        Tells Django to use specified test runner class
                        instead of the one specified by the TEST_RUNNER
                        setting.
  --liveserver=LIVESERVER
                        Overrides the default address where the live server
                        (used with LiveServerTestCase) is expected to run
                        from. The default value is localhost:8081.
  -t TOP_LEVEL, --top-level-directory=TOP_LEVEL
                        Top level of project for unittest discovery.
  -p PATTERN, --pattern=PATTERN
                        The test matching pattern. Defaults to test*.py.
  --version             show program's version number and exit
  -h, --help            show this help message and exit

如您所见,您可以通过添加来设置详细级别: -v [level]

尝试例如:python manage.py test -v 3

于 2014-04-30T10:09:20.070 回答
0

如果您想要每次测试的时间以及一些额外的信息,请查看django-juno-testrunner作为一个选项。我们想从我们的测试运行中获得更多信息,所以我们内置了它。

请注意,目前它只是 Django 1.6+

于 2014-04-30T12:10:48.263 回答