I would like to have some background unit tests run automatically continuously.
Can this be done in PyCharm ?
To set a test runner, press Ctrl+Alt+S to open the IDE settings and select Tools | Python Integrated Tools, and then select the target test runner from the Default test runner list.
Right-click the Run tool window and select the Pause Output toggle in the context menu. Note that only the output will be suspended. The program execution will be continued. To resume the program output, deselect Pause Output in the context menu.
In pycharm 2019.2, you can simply do this to run all tests: Run > Edit Configurations > Add pytest Set options as shown in following screenshot Click on Debug (or run pytest using e.g. hotkeys Shift+Alt+F9)
Open the Settings/Preferences | Tools | Python Integrated Tools settings dialog as described in Choosing Your Testing Framework. In the Default test runner field select pytest. Click OK to save the settings. There is a PyCharm documentation: Run/Debug Configuration: pytest available as of SEP 2020.
For Django versions 1.1 and later, PyCharm supports custom test runner, if this test runner is a class. By default, all tests are executed one by one.
Use this dialog to create a run/debug configuration for Python unit tests. Click one of the radio-buttons to choose the possible target.: Module name: by using a Python module name and a test class instance. Script path: by using a path to a Python file. Custom: by using an arbitrary combination of paths, modules, and test class instances.
This is very simple. Once you have created a run configuration for the unit tests, run them once manually. With the Run dialog open you will notice on the left hand size there are a group of icons arranged vertically. In that group is an icon with a circular arrow. Click that for the auto-run you seek. It behaves smartly. It doesn't just run continuously, but rather waits for you to make some changes in the code and for your to quiesce for a few seconds. At that point it appears you would be done with a change and the auto-repeat fires.
Please also see https://www.jetbrains.com/pycharm/help/rerunning-tests.html for some other great tips, such as only running failed tests.
I am late with answer, but here is official PyCharm documentation. The delay between your change and re-run can be decreased
https://www.jetbrains.com/pycharm/guide/tips/auto-run-tests/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With