.jar file can be built in Github Actions with script publish-plugin-and-cli-from-branch.
-
Required Java version: 11.
-
Preferred Python version: 3.10-3.11 (3.9 also supported but with limited functionality).
Make sure that your Python has
pipinstalled (this is usually the case). Read more about pip installation.Before running utbot install pip requirements (or use
--install-requirementsflag ingenerate_pythoncommand):python -m pip install mypy==1.0 utbot_executor==0.9.19 utbot_mypy_runner==0.2.16
Generate tests:
java -jar utbot-cli-python.jar generate_python dir/file_with_sources.py -p <PYTHON_PATH> -o generated_tests.py -s dir
This will generate tests for top-level functions from file_with_sources.py.
Run generated tests:
java -jar utbot-cli-python.jar run_python generated_tests.py -p <PYTHON_PATH>
-
-s, --sys-path <dir1>,<dir2>(required) Directories to add to
sys.path. One of directories must contain the file with the methods under test.sys.pathis a list of strings that specifies the search path for modules. It must include paths for all user modules that are used in imports. -
-p, --python-path <path>(required) Path to Python interpreter.
-
-o, --output <filename>(required) File for generated tests.
-
--coverage <filename>File to write coverage report.
-
-c, --class <class>Specify top-level (ordinary, not nested) class under test. Without this option tests will be generated for top-level functions.
-
-m, --methods <method1>,<method2>Specify methods under test.
-
--install-requirementsInstall Python requirements if missing.
-
--do-not-minimizeTurn off minimization of the number of generated tests.
-
--do-not-check-requirementsTurn off Python requirements check (to speed up).
-
-t, --timeout INTSpecify the maximum time in milliseconds to spend on generating tests (60000 by default).
-
--timeout-for-run INTSpecify the maximum time in milliseconds to spend on one function run (2000 by default).
-
--test-framework [pytest|Unittest]Test framework to be used.
-
--runtime-exception-behaviour [PASS|FAIL]Expected behaviour for runtime exception.
-
--do-not-generate-regression-suiteGenerate regression test suite or not. Regression suite and error suite generation is active by default.
-
-p, --python-path <path>(required) Path to Python interpreter.
-
--test-framework [pytest|Unittest]Test framework of tests to run.
-
-o, --output <filename>Specify file for report.
- Unittest can not run tests from parent directories