-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomponent---src-docs-cpp-command-line-interface-md-8a27397c2603a63f9a92.js
2 lines (2 loc) · 14.2 KB
/
component---src-docs-cpp-command-line-interface-md-8a27397c2603a63f9a92.js
1
2
"use strict";(self.webpackChunkunittestbot_web=self.webpackChunkunittestbot_web||[]).push([[684],{50403:function(e,t,n){n.r(t),n.d(t,{_frontmatter:function(){return l},default:function(){return u}});var a=n(87462),o=n(63366),r=(n(15007),n(64983)),s=n(23017),i=(n(13879),["components"]),l={};void 0!==l&&l&&l===Object(l)&&Object.isExtensible(l)&&!Object.prototype.hasOwnProperty.call(l,"__filemeta")&&Object.defineProperty(l,"__filemeta",{configurable:!0,value:{name:"_frontmatter",filename:"src/docs/cpp/command-line-interface.md"}});var p={_frontmatter:l},c=s.Z;function u(e){var t=e.components,n=(0,o.Z)(e,i);return(0,r.kt)(c,(0,a.Z)({},p,n,{components:t,mdxType:"MDXLayout"}),(0,r.kt)("h1",{id:"command-line-interface"},"Command Line Interface"),(0,r.kt)("p",null,(0,r.kt)("strong",{parentName:"p"},"Command Line Interface (CLI)")," allows users to get access to all UnitTestBot features via command line without any\nspecific client (i.e. VSCode)."),(0,r.kt)("p",null,"All the commands that are provided in UnitTestBot extension for Microsoft Visual Studio Code can be accessed directly\nfrom the terminal."),(0,r.kt)("p",null,"Command Line Interface is essential for the ones who need to generate tests for really big projects, then run them and\ncollect coverage information. What's more, UTBot CLI version allows to run your custom generation and running scenarios\ncombining them with some external tools."),(0,r.kt)("p",null,(0,r.kt)("strong",{parentName:"p"},"UnitTestBot CLI")," is a part of a server executable and can be downloaded from ",(0,r.kt)("a",{parentName:"p",href:"https://github.com/UnitTestBot/UTBotCpp/releases"},"release page"),"."),(0,r.kt)("p",null,"The executable provides several commands: it allows user to run server or CLI commands. If no command is specified,\nserver will be run. In order to learn more about utbot executable features use ",(0,r.kt)("inlineCode",{parentName:"p"},"-h/--help")," option."),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-sh"},"user@laptop:~$ ./utbot --help\nUnit tests auto-generation tool for C projects.\nUsage: ./utbot [OPTIONS] [SUBCOMMAND]\n\nOptions:\n -h,--help Print this help message and exit\n --help-all Expand all help\n\nSubcommands:\n server Launch UTBot server.\n generate Generate unit tests and/or stubs.\n run Launch unit tests and generate coverage info.\n all Sequential launch of 'generate stubs' -> 'generate project' -> 'run'.\n")),(0,r.kt)("p",null,"In case to read all information, please use ",(0,r.kt)("inlineCode",{parentName:"p"},"--help-all")," option. It will display all the manual."),(0,r.kt)("h2",{id:"server-command"},"Server Command"),(0,r.kt)("p",null,"In order to run UTBot in server mode, please use ",(0,r.kt)("inlineCode",{parentName:"p"},"server")," subcommand. The command options can be viewed\nvia ",(0,r.kt)("inlineCode",{parentName:"p"},"./utbot server --help"),"."),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-sh"},"user@laptop:~$ ./utbot server --help\nLaunch UTBot server.\nUsage: ./utbot server [OPTIONS]\n\nOptions:\n -h,--help Print this help message and exit\n --help-all Expand all help\n -p,--port UINT Port server run on.\n -j UINT Maximum number of threads per user.\n --tmp TEXT Path to temporary folder.\n --log TEXT Path to folder with logs.\n -v,--verbosity ENUM:value in {debug|error|info|trace|warning}:value in {debug->1,error->-2,info->0,trace->9,warning->-1} OR {1,-2,0,9,-1}\n Logger verbosity.\n")),(0,r.kt)("h3",{id:"examples"},"Examples"),(0,r.kt)("p",null,"Let us provide with several examples of how you can run UnitTestBot executable in server mode."),(0,r.kt)("p",null,"In case you are fine with default settings you can avoid passing parameters and just run executable."),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-sh"},"user@laptop:~$ ./utbot\n")),(0,r.kt)("p",null,"If you want to be more specific in terms of your settings (e.g., change port and log folder), run it accordingly:"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-sh"},'user@laptop:~$ ./utbot --port 2130 --log "/home/utbot/logs".\n')),(0,r.kt)("h2",{id:"generate-command"},"Generate Command"),(0,r.kt)("p",null,"If you want to generate tests for the source code, you need to use ",(0,r.kt)("inlineCode",{parentName:"p"},"generate")," subcommand. The command options can be\nviewed via ",(0,r.kt)("inlineCode",{parentName:"p"},"./utbot generate --help"),"."),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-sh"},"user@laptop:~$ ./utbot generate --help\nGenerate unit tests and/or stubs.\nUsage: ./utbot generate [OPTIONS] SUBCOMMAND\n\nOptions:\n -h,--help Print this help message and exit\n --help-all Expand all help\n[Option Group: Project context]\n Options:\n -p,--project-path TEXT REQUIRED\n Path to testing project root.\n -t,--tests-dir TEXT=tests Relative path to directory in which tests will be generated.\n -b,--build-dir TEXT=build Relative path to build directory with compile_commands.json and/or coverage.json.\n[Option Group: Settings context]\n Options:\n -g,--generate-for-static True, if you want UTBot to generate tests for static functions.\n -v,--verbose Set if Five Rules Standard is required.\n --timeout INT=30 Maximum time (in seconds) is allowed for generation tests per function. Set to non-positive number to disable it.\n --no-deterministic-searcher Use deterministic searcher to traverse bitcode in the same way every time. It may significantly slow down generation.\n --no-stubs True, if you don’t want UTBot to use generated stubs from <testsDir>/stubs folder instead real files.\n\nSubcommands:\n project Generate tests for C project.\n stubs Generate stubs for project.\n folder Generate tests for folder.\n file Generate tests for file in project.\n snippet Generate tests for code snippet.\n function Generate tests for function.\n class Generate tests for C++ class.\n line Generate tests for line in file.\n assertion Generate tests that fails assertion.\n predicate Generate tests with given result.\n")),(0,r.kt)("p",null,"The command provides other subcommands, that specify test generation mode. It's required to use one. These subcommands\nmay require additional options (i.e., ",(0,r.kt)("inlineCode",{parentName:"p"},"--line-number"),") in order to run them. Existing options can be displayed\nvia ",(0,r.kt)("inlineCode",{parentName:"p"},"./utbot generate [SUBCOMMAND] --help"),". You can also check them via global ",(0,r.kt)("inlineCode",{parentName:"p"},"--help-all")," option."),(0,r.kt)("p",null,"Generated tests can be found in a test folder (",(0,r.kt)("inlineCode",{parentName:"p"},"tests")," subfolder in the project directory by default)."),(0,r.kt)("h3",{id:"examples-1"},"Examples"),(0,r.kt)("p",null,"Below we demonstrate several examples of how to run generation commands."),(0,r.kt)("p",null,(0,r.kt)("strong",{parentName:"p"},"Generate tests for snippet")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-sh"},'user@laptop:~$ ./utbot generate --project-path "/home/snippets/" snippet --file-path "home/snippets/snippet.c"\n')),(0,r.kt)("p",null,"Here, ",(0,r.kt)("inlineCode",{parentName:"p"},"--project-path")," is path to the parent directory of the given snippet file ",(0,r.kt)("inlineCode",{parentName:"p"},"snippet.c"),"."),(0,r.kt)("p",null,(0,r.kt)("strong",{parentName:"p"},"Generate tests for project")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-sh"},'user@laptop:~$ ./utbot generate --project-path "/home/projects/c-project" project\n')),(0,r.kt)("p",null,(0,r.kt)("strong",{parentName:"p"},"Generate tests for function")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-sh"},'user@laptop:~$ ./utbot generate --project-path "/home/projects/c-project" function --file-path /home/projects/c-project/complex_structs.c --line-number 39\n')),(0,r.kt)("p",null,(0,r.kt)("strong",{parentName:"p"},"Generate tests with prompted result")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-sh"},'user@laptop:~$ ./utbot generate --project-path "/home/projects/c-project/" predicate --file-path "/home/projects/c-project/basic_functions.c" --line-number 5 --predicate == --return-value 11 --validation-type int32\n')),(0,r.kt)("h2",{id:"run-command"},"Run Command"),(0,r.kt)("p",null,"One of the main features of UnitTestBot that allows to run tests with coverage is available in CLI mode as well. In\norder to run the tests, type in the following command: ",(0,r.kt)("inlineCode",{parentName:"p"},"./utbot run [OPTIONS] [SUBCOMMAND] [SUBCOMMAND OPTIONS]>"),".\nSubcommand in this case specifies whether to run all generated tests, tests in one file, or just one specific test."),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-sh"},"user@laptop:~$ ./utbot run --help\nLaunch unit tests and generate coverage info.\nUsage: ./utbot run [OPTIONS] [SUBCOMMAND]\n\nOptions:\n -h,--help Print this help message and exit\n --help-all Expand all help\n[Option Group: Project context]\n Options:\n -p,--project-path TEXT REQUIRED\n Path to testing project root.\n -t,--tests-dir TEXT=tests Relative path to directory in which tests will be generated.\n -b,--build-dir TEXT=build Relative path to build directory with compile_commands.json and/or coverage.json.\n[Option Group: Settings context]\n Options:\n -g,--generate-for-static True, if you want UTBot to generate tests for static functions.\n -v,--verbose Set if Five Rules Standard is required.\n --timeout INT=30 Maximum time (in seconds) is allowed for generation tests per function. Set to non-positive number to disable it.\n --no-deterministic-searcher Use deterministic searcher to traverse bitcode in the same way every time. It may significantly slow down generation.\n --no-stubs True, if you don’t want UTBot to use generated stubs from <testsDir>/stubs folder instead real files.\n\nSubcommands:\n test Run specified test\n file Run all tests in specified file\n project Run all tests for this project\n")),(0,r.kt)("p",null,"Similiarly to ",(0,r.kt)("inlineCode",{parentName:"p"},"generate")," subcommands, you can access manual for ",(0,r.kt)("inlineCode",{parentName:"p"},"run")," subcommands via ",(0,r.kt)("inlineCode",{parentName:"p"},"./utbot run [SUBCOMMAND] --help"),"."),(0,r.kt)("h3",{id:"examples-2"},"Examples"),(0,r.kt)("p",null,(0,r.kt)("strong",{parentName:"p"},"Run all tests for project")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-sh"},'user@laptop:~$ ./utbot run --project-path "/home/projects/c-project" project\n')),(0,r.kt)("p",null,(0,r.kt)("strong",{parentName:"p"},"Run test file")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-sh"},'user@laptop:~$ ./utbot run --project-path "/home/projects/c-project" file --file-path "home/projects/c-project/tests/basic_functions_test.cpp" \n')),(0,r.kt)("p",null,(0,r.kt)("strong",{parentName:"p"},"Run specific test")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-sh"},'user@laptop:~$ ./utbot run --project-path "/home/projects/c-project" test --file-path "/home/projects/c-project/tests/basic_functions_test.cpp" --test-suite "regression" --test-name "max__test_1"\n')),(0,r.kt)("h2",{id:"all-command"},"All Command"),(0,r.kt)("p",null,"For simplicity, UTBot CLI provides ",(0,r.kt)("inlineCode",{parentName:"p"},"all")," command, that firstly generates stubs for the project, then generates project\ntests and finally runs them with coverage."),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-sh"},"user@laptop:~$ ./utbot all --help\nSequential launch of 'generate stubs' -> 'generate project' -> 'run'.\nUsage: ./utbot all [OPTIONS]\n\nOptions:\n -h,--help Print this help message and exit\n --help-all Expand all help\n --no-coverage BOOLEAN Flag that controls coverage generation.\n -s,--src-paths TEXT Relative paths to directories, containing source files. Separate each path with comma.\n[Option Group: Project context]\n Options:\n -p,--project-path TEXT REQUIRED\n Path to testing project root.\n -t,--tests-dir TEXT=tests Relative path to directory in which tests will be generated.\n -b,--build-dir TEXT=build Relative path to build directory with compile_commands.json and/or coverage.json.\n[Option Group: Settings context]\n Options:\n -g,--generate-for-static True, if you want UTBot to generate tests for static functions.\n -v,--verbose Set if Five Rules Standard is required.\n --timeout INT=30 Maximum time (in seconds) is allowed for generation tests per function. Set to non-positive number to disable it.\n --no-deterministic-searcher Use deterministic searcher to traverse bitcode in the same way every time. It may significantly slow down generation.\n --no-stubs True, if you don’t want UTBot to use generated stubs from <testsDir>/stubs folder instead real files.\n")),(0,r.kt)("h3",{id:"examples-3"},"Examples"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-sh"},'user@laptop:~$ ./utbot all --project-path "/home/projects/c-project"\n')))}u&&u===Object(u)&&Object.isExtensible(u)&&!Object.prototype.hasOwnProperty.call(u,"__filemeta")&&Object.defineProperty(u,"__filemeta",{configurable:!0,value:{name:"MDXContent",filename:"src/docs/cpp/command-line-interface.md"}}),u.isMDXComponent=!0}}]);
//# sourceMappingURL=component---src-docs-cpp-command-line-interface-md-8a27397c2603a63f9a92.js.map