.jar file can be built in Github Actions with script publish-plugin-and-cli-from-branch.
-
Required Java version: 11.
-
Prefered Python version: 3.8 or 3.9.
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==0.971 astor typeshed-client coverage
Generate tests:
java -jar utbot-cli.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.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).
-
--visit-only-specified-sourceDo not search for classes and imported modules in other Python files from
--sys-pathoption. -
-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.
-
-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