You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unit test generation does not work for python in PyCharm #2670
If I select "Generate..." from the context menu in PyCharm, I would expect to see an option
"Test with UnitTestBot..." as shown in the Video of the Extension:
However, the option is missing.
=> How to use UnitTestBot for Python code in PyCharm?
"UnitTestBot for Java/Kotlin, C/C++, Python, JavaScript, and Go."
If the extension does not support PyCharm/Python, please write so in the plugin description or disable the extension to be shown for PyCharm.
Hi,
Release version works in IDEA only, with installed Python plugin you could generate tests for Python there. Don't forget to enable Experimental language support in UTBot settings.
PyCharm support is in development at the moment, you may try it by installing plugin from main branch. Download utbot-intellij-PY-main-2023.10.5369 from here and use Install from disk option from Plugin settings.
We will look how to prevent installation of improper plugin version from the Market.
Thank you very much for the fast answer. I tried to enable Experimental language support in the already installed version. Now I get the expected menu option. However, the test generation fails with a NoClassDefFoundError.
Regarding folders: it's better to have dedicated folder as I see on your screenshot test folder at the same level as src. You may point UTBot in the dialog:
About error in the code: have you moved the test file from another folder or added second line yourself?
Ah. I misinterpretet the meaning of the option. I selected the src folder. But it should be the test folder, I guess. Maybe a better name would be "Test destination root" or so.
After selecting test as "Test soruces root" now the genrated test is test/test_src_foo_foo_foo.py.
However, I would expect test/foo/test_foo.py
where UnitTestBot automatically detects the sub folders structure within src and applies a similar structure for the generated tests.
Activity
tyuldashev commentedon Nov 2, 2023
Hi,
Release version works in IDEA only, with installed Python plugin you could generate tests for Python there. Don't forget to enable
Experimental language supportin UTBot settings.PyCharm support is in development at the moment, you may try it by installing plugin from
mainbranch. Downloadutbot-intellij-PY-main-2023.10.5369from here and useInstall from diskoption from Plugin settings.We will look how to prevent installation of improper plugin version from the Market.
fhg-isi commentedon Nov 2, 2023
Thank you very much for the fast answer. I tried to enable Experimental language support in the already installed version. Now I get the expected menu option. However, the test generation fails with a NoClassDefFoundError.
Then I installed
https://github.com/UnitTestBot/UTBotJava/suites/17746700914/artifacts/1016410535
After running the command again, I got a new menu and was asked to install some missing dependencies. I did so.
Now the extension actually generates some test file.
However, it is not located at the expected target location. Also see
https://stackoverflow.com/questions/77409726/ho-to-generate-unit-tests-for-python-in-pycharm-using-src-and-test-folder-stru
tyuldashev commentedon Nov 2, 2023
Regarding folders: it's better to have dedicated folder as I see on your screenshot

testfolder at the same level assrc. You may point UTBot in the dialog:About error in the code: have you moved the test file from another folder or added second line yourself?
fhg-isi commentedon Nov 2, 2023
Ah. I misinterpretet the meaning of the option. I selected the
srcfolder. But it should be thetestfolder, I guess. Maybe a better name would be "Test destination root" or so.After selecting
testas "Test soruces root" now the genrated test istest/test_src_foo_foo_foo.py.However, I would expect
test/foo/test_foo.pywhere UnitTestBot automatically detects the sub folders structure within
srcand applies a similar structure for the generated tests.tyuldashev commentedon Nov 13, 2023
UnitTest bot for PyCharm is available through Marketplace now. Also we hide UTBot for IDEA from the search in PyCharm.