Home > Blockchain >  How to run unitest from specific file?
How to run unitest from specific file?

Time:02-12

In my project I have a task to add few Unittests to APIs. We have many django apps and I need to do work only with one:

apps\data\tests.py

But when I'm trying to specify exactly this file/folder to start those exact Tests:

python3 manage.py test data.tests

or

python3 manage.py test data.tests.py

its still running ALL tests between ALL apps. I did make 1 hour search online but Everyone suggesting to use:

 python3 manage.py test    "path to the folder/file".

But its still running everything. Maybe i'm missing some General test configuration in settings.py?

Thank you,

CodePudding user response:

You need to start from your app name. To run tests only from file tests.py in app apps run:

python3 manage.py test apps.data.tests

To run specific TestCase, run:

python3 manage.py test apps.data.tests.MyTestCase

or even only single test:

python3 manage.py test apps.data.tests.MyTestCase.my_first_test
  • Related