1

I am using Django unit test framework for testing my application. When ever I am executing all the test cases I am getting very brief information about the test cases that ran successfully.

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

OK

This is the very little information. I wanted to have some more information about each test case,

e.g.

Time taken by each test case to execute.

successful completion of each test module. etc etc.

Do we have any debug(or any other parameter) parameter that can enable this extended information about the test cases that got executed?

NOTE:- using verbosity parameter does not satisfy my needs

Bhupesh Pant
  • 4,053
  • 5
  • 45
  • 70

2 Answers2

0

Each django command has a --help option, if you type:

python manage.py test --help you will see all the available options for the command 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

As you can see you can set a verbosity level by adding: -v [level]

Try for example with: python manage.py test -v 3

daveoncode
  • 18,900
  • 15
  • 104
  • 159
  • Thanks for your prompt reply. But this parameter does not helps me. I have tried it actually. it only gives me the the name of the executing testcase and the status of the testcase. I mainly wanted to have the time spend on each test case. – Bhupesh Pant Apr 30 '14 at 10:15
  • mmm perhaps you may write your custom TestRunner to add extra informations to the logs... but... is it really helpful to know how much a test takes? (considering that they runs very very fast, and that time is not a reliable indicator of the speed achieved by your code implementation) – daveoncode Apr 30 '14 at 10:25
  • Actually we are doing distributed development for our project. I think this could be a way to figure out the time taken by some function. Actually I have used this feature in visual studio integrated test framework.. Do you have some comments to enlighten me? – Bhupesh Pant Apr 30 '14 at 10:37
0

If you want the time for each test, plus some extra info, check out django-juno-testrunner as one option. We wanted more info out of our test runs, so we built it in.

Note that it's Django 1.6+ only at the moment

Steve Jalim
  • 11,989
  • 1
  • 37
  • 54