Is it possible to run tests from multiple test directories?
I have a Django (if it matters) application, structured approximately this way.
/main
/foo
/class1.py
/tests
/test_class1.py
/bar
/class2.py
/tests
/test_class2.py
Under PyCharm's test configuration, it's no problem for me to test "All in folder". Unfortunately, I'm restricted to testing one folder at a time. I've tried...
a) combining the directories with my test files with
i) a comma separator
ii) a semicolon separator
b) using globs
i) \main\*\tests
ii) \main\**\tests
Neither of these worked for me. I could set up a test configuration for each smaller application, but I know this will lead to me forgetting to run tests and making an embarrassing mistake Real Soon Now.
Is there a way to accomplish this or am I just doing everything completely wrong?
/main
/foo
/class1.py
/tests
/test_class1.py
/bar
/class2.py
/tests
/test_class2.py
Under PyCharm's test configuration, it's no problem for me to test "All in folder". Unfortunately, I'm restricted to testing one folder at a time. I've tried...
a) combining the directories with my test files with
i) a comma separator
ii) a semicolon separator
b) using globs
i) \main\*\tests
ii) \main\**\tests
Neither of these worked for me. I could set up a test configuration for each smaller application, but I know this will lead to me forgetting to run tests and making an embarrassing mistake Real Soon Now.
Is there a way to accomplish this or am I just doing everything completely wrong?
请先登录再写评论。
please, try to use Django Tests run configuration instead of unittests one.
You may go to Run-> Edit configuration and create it manually (type target in appropriate field) or
just right click on application and select Run Django Tests (this is available if Settings->Django Support is correct)
I tried to configure Django Tests to run everything. According to http://www.jetbrains.com/pycharm/webhelp/run-debug-configuration-django-test.html "all the tests in all the applications specified in INSTALLED_APPS will be executed"; when I try it, I'm not seeing any tests executed, probably because I put them in a /tests sub-folder and not in tests.py. Looking at the output from the test run, I see that PyCharm is attempting to assemble tests.py on the fly for me, but it's ultimately failing to find any.
I'm left with a second problem - running this runs all the Django unit tests (which is pretty time-consuming) and a large number of them are failing, leaving me buried under noise. In PyCharm's test configuration, I'm not able to target more than one of my applications.