I'm using unittest
library to run some tests for a Python/Django application, using Visual Studio Code. They work just fine. The only issue is that I have the tests located in more than one file, and I can't get VS Code to run them all at one single click, I have to run each file separately. My structure goes something like this:
/applications (folder)
/folder1
python_file_1.py
python_file_2.py
...
test_first.py
/folder2
python_file_3.py
python_file_4.py
...
test_second.py
test_third.py
This produces this tree in the test explorer:
The files test_*.py
contain my three sets of tests but, like I said, I can only run them one at a time. If I click on the play
button at /applications
level, VS Code only runs the tests in test_integration_comun.py
file. Is there a way to run all 3 with just one click?
This is the settings.json
file that VS Code added when I configured unittest
:
{
"python.testing.unittestArgs": [
"-v",
"-s",
"./applications",
"-p",
"test_*.py"
],
"python.testing.pytestEnabled": false,
"python.testing.unittestEnabled": true
}
Thanks in advance for the help :)
To run all discovered tests, select the play button at the top of Test Explorer:
To run a specific group of tests, or a single test, select the file, class, or test, then select the play button to the right of that item: