From bdec1cf20220693797d9e5df9b5b4649e74f1c94 Mon Sep 17 00:00:00 2001 From: Achanandhi-M Date: Wed, 7 Jan 2026 13:06:20 +0530 Subject: [PATCH] feat: deprecate gen command in version 3.0.0 cli Signed-off-by: Achanandhi-M --- .../running-keploy/cli-commands.md | 321 ++++++++++-------- 1 file changed, 179 insertions(+), 142 deletions(-) diff --git a/versioned_docs/version-3.0.0/running-keploy/cli-commands.md b/versioned_docs/version-3.0.0/running-keploy/cli-commands.md index 6cfdcb3e5..cf80e4bf2 100755 --- a/versioned_docs/version-3.0.0/running-keploy/cli-commands.md +++ b/versioned_docs/version-3.0.0/running-keploy/cli-commands.md @@ -27,15 +27,16 @@ You can use `--help, -h` flag for all the commands to see available flag options Here are some examples of how to use some common flags: -| Command | Flags Available | -| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `record` | `-c, --command`, `--config-path`, `--containerName`, `-d, --delay`, `--metadata`, `-n, --networkName`, `--passThroughPorts`, `-p, --path`, `--proxyport`, `--debug` | -| `test` | `--apiTimeout`, `-c, --command`, `--config-path`, `--containerName`, `-d, --delay`, `--mongoPassword`, `-n, --net, --networkName`, `--passThroughPorts`, `-p, --path`, `--proxyport`, `-t, --testsets`, `--debug`, `-g, --generateTestReport`, `--removeUnusedMocks`, `--coverage`, `--goCoverage`, `--ignoreOrdering`, `--skip-preview`, `--proto-dir`, `--proto-file`, `--proto-include` | -| `normalize` | `-p, --path`, `--test-run`, `--tests` | -| `rerecord` | `--test-sets`, `-t` | -| `report` | `--test-sets, -t`, `-p, --path`, `--report-path, -r`, `--body` | -| `sanitize` | `--test-sets, -t`, `-p, --path` | -| `config` | `--generate`,`-p, --path` | +| Command | Flags Available | +| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `record` | `-c, --command`, `--config-path`, `--containerName`, `-d, --delay`, `--metadata`, `-n, --networkName`, `--passThroughPorts`, `-p, --path`, `--proxyport`, `--debug` | +| `test` | `--apiTimeout`, `-c, --command`, `--config-path`, `--containerName`, `-d, --delay`, `--mongoPassword`, `-n, --net, --networkName`, `--passThroughPorts`, `-p, --path`, `--proxyport`, `-t, --testsets`, `--debug`, `-g, --generateTestReport`, `--removeUnusedMocks`, `--coverage`, `--goCoverage`, `--ignoreOrdering`, `--skip-preview`, `--proto-dir`, `--proto-file`, `--proto-include` | +| `gen` (Deprecated) | `--sourceFilePath`, `--testFilePath`,`--coverageReportPath`,`--testCommand`,`--coverageFormat`,`--expectedCoverage`,`--maxIterations`,`--testDir`,`--llmBaseUrl`,`--model`,`--llmApiVersion` | +| `normalize` | `-p, --path`, `--test-run`, `--tests` | +| `rerecord` | `--test-sets`, `-t` | +| `report` | `--test-sets, -t`, `-p, --path`, `--report-path, -r`, `--body` | +| `sanitize` | `--test-sets, -t`, `-p, --path` | +| `config` | `--generate`,`-p, --path` | ## [record](#record) @@ -51,76 +52,76 @@ keploy record [flags] - `-c, --command string` - Command required to start the user application. - ```bash - keploy record --command "node src/app.js" - ``` +```bash +keploy record --command "node src/app.js" +``` - In the command above, `node src/app.js` is the command which starts the user application. +In the command above, `node src/app.js` is the command which starts the user application. - `--config-path string` - Path to the Keploy configuration file. The default is ".". - ```bash - keploy record -c "node src/app.js" --config-path "./config-dir/" - ``` +```bash +keploy record -c "node src/app.js" --config-path "./config-dir/" +``` - In the above command, `config-dir` is the directory in the CWD where the Keploy configuration file `keploy.yaml` is stored. +In the above command, `config-dir` is the directory in the CWD where the Keploy configuration file `keploy.yaml` is stored. - `--container-name string` - Name of the docker container in which the user application is running. - ```bash - keploy record -c "docker compose up" --container-name "my-app-container" - ``` +```bash +keploy record -c "docker compose up" --container-name "my-app-container" +``` - `-d, --delay uint` - Delay in seconds to run user application. The default is 5 seconds. - ```bash - keploy record -c "node src/app.js" -d 10 - ``` +```bash +keploy record -c "node src/app.js" -d 10 +``` - `--metadata string` - Key-value pairs to be added as metadata in the config.yaml file. If a `name` key is provided, it will be used as the test set name. - ```bash - keploy record -c "node src/app.js" --metadata "name=mac,env=production,service=gin-mongo,version=2.0.0,team.members[0]=alice,team.members[1]=bob,team.members[2]=carol,labels[0]=canary,labels[1]=stable,config.timeout=30s,config.timeout=60s,complex=a\\,b\\,c\\,d,database.urls[0]=db1.internal,database.urls[1]=db2.internal,database.urls[2]=db3.internal,mode=fast,mode=slow" - ``` +```bash +keploy record -c "node src/app.js" --metadata "name=mac,env=production,service=gin-mongo,version=2.0.0,team.members[0]=alice,team.members[1]=bob,team.members[2]=carol,labels[0]=canary,labels[1]=stable,config.timeout=30s,config.timeout=60s,complex=a\\,b\\,c\\,d,database.urls[0]=db1.internal,database.urls[1]=db2.internal,database.urls[2]=db3.internal,mode=fast,mode=slow" +``` - ```bash - keploy record -c "node src/app.js" --metadata "name=mac,env=production,service=gin-mongo,version=2.0.0,team.members[0]=alice,team.members[1]=bob,team.members[2]=carol,labels[0]=canary,labels[1]=stable,config.timeout=30s,config.timeout=60s,complex=a\\,b\\,c\\,d,database.urls[0]=db1.internal,database.urls[1]=db2.internal,database.urls[2]=db3.internal,mode=fast,mode=slow" - ``` +```bash +keploy record -c "node src/app.js" --metadata "name=mac,env=production,service=gin-mongo,version=2.0.0,team.members[0]=alice,team.members[1]=bob,team.members[2]=carol,labels[0]=canary,labels[1]=stable,config.timeout=30s,config.timeout=60s,complex=a\\,b\\,c\\,d,database.urls[0]=db1.internal,database.urls[1]=db2.internal,database.urls[2]=db3.internal,mode=fast,mode=slow" +``` - > **Note:** If the same key is used multiple times, the last occurrence will be used. +> **Note:** If the same key is used multiple times, the last occurrence will be used. - `- n, --network-name string` - Name of the docker network in which the user application is running. - ```bash - keploy record -c "docker compose up" --container-name "my-app-container" -n "my-app-network" - ``` +```bash +keploy record -c "docker compose up" --container-name "my-app-container" -n "my-app-network" +``` - `--pass-through-ports uints` - Ports of outgoing dependency calls to be ignored as mocks and passed through to the actual dependency. The default is no ports. - `-p, --path string` - Path to the local directory where the recorded testcases and generated mocks are to be saved. - ```bash - keploy record -c "node src/app.js" -p "./tests" - ``` +```bash +keploy record -c "node src/app.js" -p "./tests" +``` - In the above command, `tests` is the directory in the CWD where the recorded testcases and generated mocks are to be stored. +In the above command, `tests` is the directory in the CWD where the recorded testcases and generated mocks are to be stored. - `--proxy-port uint32` - Port to choose to run Keploy as a proxy. The default is 16789. - ```bash - keploy record -c "node src/app.js" --proxy-port 8080 - ``` +```bash +keploy record -c "node src/app.js" --proxy-port 8080 +``` - `--debug` - To start recording testcases with debug mode enabled. - ```bash - keploy record -c "node src/app.js" --debug - ``` +```bash +keploy record -c "node src/app.js" --debug +``` - `rerecord` - Record certain test-sets again - ```bash - keploy record -c "node src/app.js" --rerecord "test-set-0" - ``` +```bash +keploy record -c "node src/app.js" --rerecord "test-set-0" +``` ## [test](#test) @@ -136,125 +137,161 @@ keploy test [flags] - `--api-timeout uint` - Timeout in seconds for calling user application. The default is 5 seconds. - ```bash - keploy test -c "node src/app.js" --api-timeout 10 - ``` +```bash +keploy test -c "node src/app.js" --api-timeout 10 +``` - `-c, --command string` - Command required to start the user application. - ```bash - keploy test -c "node src/app.js" - ``` +```bash +keploy test -c "node src/app.js" +``` - In the command above, `node src/app.js` is the command which starts the user application. +In the command above, `node src/app.js` is the command which starts the user application. - `--config-path string` - Path to the Keploy configuration file. The default is ".". - ```bash - keploy test -c "node src/app.js" --config-path "./config-dir/" - ``` +```bash +keploy test -c "node src/app.js" --config-path "./config-dir/" +``` - In the above command, `config-dir` is the directory in the CWD where the Keploy configuration file `keploy.yaml` is stored. +In the above command, `config-dir` is the directory in the CWD where the Keploy configuration file `keploy.yaml` is stored. - `--container-name string` - Name of the docker container in which the user application is running. - ```bash - keploy test -c "docker compose up" --container-name "my-app-container" - ``` +```bash +keploy test -c "docker compose up" --container-name "my-app-container" +``` - `-d, --delay uint` - Delay in seconds to run user application. The default is 5 seconds. - ```bash - keploy test -c "node src/app.js" --delay 10 - ``` +```bash +keploy test -c "node src/app.js" --delay 10 +``` - `--mongo-password string` - Authentication password for mocking MongoDB connection. The default password is "default123". - ```bash - keploy test -c "node src/app.js" --mongo-password "my-password" - ``` +```bash +keploy test -c "node src/app.js" --mongo-password "my-password" +``` - `- n, --network-name string` - Name of the docker network in which the user application is running. - ```bash - keploy test -c "docker compose up" --container-name "my-app-container" -n "my-app-network" -d 9 - ``` +```bash +keploy test -c "docker compose up" --container-name "my-app-container" -n "my-app-network" -d 9 +``` - `--pass-through-ports uints` - Ports of outgoing dependency calls to be ignored as mocks and passed through to the actual dependency. The default is no ports. - `-p, --path string` - Path to the local directory where the recorded testcases and generated mocks are saved. - ```bash - keploy test -c "node src/app.js" -d 10 --path "./tests" - ``` +```bash +keploy test -c "node src/app.js" -d 10 --path "./tests" +``` - In the above command, `tests` is the directory in the CWD where the recorded testcases and generated mocks are saved. +In the above command, `tests` is the directory in the CWD where the recorded testcases and generated mocks are saved. - `--proxy-port uint32` - Port to choose to run Keploy as a proxy. The default is 16789. - ```bash - keploy test -c "node src/app.js" --proxy-port 8080 - ``` +```bash +keploy test -c "node src/app.js" --proxy-port 8080 +``` - `-t, --test-sets strings` - To specify which specific testsets are to be executed. The default is all testsets. - ```bash - keploy test -c "node src/app.js" -t "test-set-1,test-set-3" --delay 10 - ``` +```bash +keploy test -c "node src/app.js" -t "test-set-1,test-set-3" --delay 10 +``` - `--debug` - To start executing testcases with debug mode enabled. - ```bash - keploy test -c "node src/app.js" --delay 10 --debug - ``` +```bash +keploy test -c "node src/app.js" --delay 10 --debug +``` - `-g, --generate-test-report` - To generate the test report. The default is true. - ```bash - keploy test -c "node src/app.js" --delay 10 -g=false - ``` +```bash +keploy test -c "node src/app.js" --delay 10 -g=false +``` - `--remove-unused-mocks` - To remove unused mocks from mock file. The default is false. - ```bash - keploy test -c "node src/app.js" --delay 10 --remove-unused-mocks - ``` +```bash +keploy test -c "node src/app.js" --delay 10 --remove-unused-mocks +``` - `--ignore-ordering` - Ignore the order of elements in an array for a response, with the default value being true. - ```bash - keploy test -c "node src/app.js" --delay 10 --ignore-ordering - ``` +```bash +keploy test -c "node src/app.js" --delay 10 --ignore-ordering +``` - `--skip-coverage` - skip code coverage computation while running the test cases - `--skip-preview` - skip line by line code coverage preview but display the total coverage. - ```bash - keploy test -c "node src/app.js" --delay 10 --skip-preview - ``` +```bash +keploy test -c "node src/app.js" --delay 10 --skip-preview +``` - `--jacoco-agent-path` - Only applicable for test coverage for Java projects. You can override the jacoco agent jar by providing its path - `--proto-dir string` - Path of the directory where all protos of a service are located. Used for GRPC test cases to enable better deterministic and proper comparison of protobuf responses. - ```bash - keploy test -c "node src/app.js" --proto-dir "./protos" - ``` +```bash +keploy test -c "node src/app.js" --proto-dir "./protos" +``` - `--proto-file string` - Path of main proto file. Used for GRPC test cases to enable better deterministic and proper comparison of protobuf responses. Either `--proto-file` or `--proto-dir` must be provided for GRPC tests. - ```bash - keploy test -c "node src/app.js" --proto-file "./protos/main.proto" - ``` +```bash +keploy test -c "node src/app.js" --proto-file "./protos/main.proto" +``` - `--proto-include stringArray` - Path of directories to be included while parsing import statements in proto files. This is optional and used for GRPC test cases when proto files have import dependencies. - ```bash - keploy test -c "node src/app.js" --proto-file "./protos/main.proto" --proto-include "./protos/common,./protos/shared" - ``` +```bash +keploy test -c "node src/app.js" --proto-file "./protos/main.proto" --proto-include "./protos/common,./protos/shared" +``` + +> **Note for GRPC Tests:** When running GRPC test cases, it's recommended to provide proto information using either `--proto-file` or `--proto-dir` flags. If proto information is not provided, Keploy will use basic canonical matching of the protoscopic textual format of GRPC response body, which may be less accurate than proto-based comparison. + +## [gen](#gen) + +> **Deprecated:** This command is deprecated. + +The `gen` cmd in Keploy allows user to generate unit tests using LLM Models. + + Usage: + +```bash +keploy gen [flags] +``` + + Available flags: + +- `sourceFilePath` - Path to the source file for which tests are to be generated. + +- `testFilePath` - Path where the generated tests will be saved. + +- `coverageReportPath` - Path to generate the coverage report. + +- `testCommand` - Command to execute tests and generate the coverage report. + +- `coverageFormat` - Type of the coverage report by default report is in "cobertura" format. + +- `expectedCoverage` - Desired coverage percentage by default it is set to be at 100%. + +- `maxIterations` - Maximum number of iterations for refining tests (default 5). + +- `testDir` - Directory where tests will be written. + +- `llmBaseUrl` - Base url of the llm. - > **Note for GRPC Tests:** When running GRPC test cases, it's recommended to provide proto information using either `--proto-file` or `--proto-dir` flags. If proto information is not provided, Keploy will use basic canonical matching of the protoscopic textual format of GRPC response body, which may be less accurate than proto-based comparison. +- `model` - Specifies the AI model to use by default it uses "gpt-4o" model. + +- `llmApiVersion` - API version of the llm if any. ## [normalize](#normalize) @@ -272,29 +309,29 @@ keploy normalize [flags] - `-p, --path string` - Path to the local directory where the recorded testcases and generated mocks are to be saved. - ```bash - keploy normalize -p "./tests" - ``` +```bash +keploy normalize -p "./tests" +``` - In the above command, `tests` is the directory in the CWD where the recorded testcases and generated mocks are to be stored. +In the above command, `tests` is the directory in the CWD where the recorded testcases and generated mocks are to be stored. - `--test-run string` - by default normalization considers the latest test-run to change the response of the testcases but if user want to do it for a particular test-run this flag can be used. - ```bash - keploy normalize -p "./tests" --test-run "test-run-10" - ``` +```bash +keploy normalize -p "./tests" --test-run "test-run-10" +``` - `--tests string` - by default normalization considers all the testcases for normalization but if user want to normalize only few particular testcases or testsets this flag can be used - ```bash - keploy normalize -p "./tests" --test-run "test-run-10" --tests "test-set-1:test-1 test-2, test-set-2, test-set-3, test-set-4:test-3" - ``` +```bash +keploy normalize -p "./tests" --test-run "test-run-10" --tests "test-set-1:test-1 test-2, test-set-2, test-set-3, test-set-4:test-3" +``` - `--allow-high-risk` - Allow normalization of high-risk test failures. This flag overrides the default safe behavior and updates all failed tests, including those with breaking changes. - ```bash - keploy normalize --allow-high-risk - ``` +```bash +keploy normalize --allow-high-risk +``` ## [rerecord](#rerecord) @@ -336,39 +373,39 @@ keploy report [flags] - `-t, --test-sets strings` - Testsets to report, e.g., `--test-sets "test-set-1, test-set-2"`. If omitted, all test sets in the latest run are considered. - ```bash - keploy report -t "test-set-1" - ``` +```bash +keploy report -t "test-set-1" +``` - `-p, --path string` - Path to the local directory where generated testcases/mocks are stored. Default is ".". - ```bash - keploy report -p "./keploy-tests" - ``` +```bash +keploy report -p "./keploy-tests" +``` - `--report-path, -r string` - **Absolute** path to a specific report file to display results from (must point to a file, not a directory). You can still combine this with other flags like `--summary` or `--test-case`. - ```bash - keploy report --report-path "/home/user/my-app/keploy/reports/test-run-1.yaml" - ``` +```bash +keploy report --report-path "/home/user/my-app/keploy/reports/test-run-1.yaml" +``` - `--full` - Show full diffs instead of the default compact table view. For JSON bodies, this produces colorized expected/actual comparisons. - ```bash - keploy report -t "test-set-1" --full - ``` +```bash +keploy report -t "test-set-1" --full +``` - `--summary` - Print only a summarized view (grand totals and per–test-set table with time taken). Useful for a quick dashboard-style overview. Can be combined with `-t/--test-sets` and `--report-path`. - ```bash - keploy report --summary - ``` +```bash +keploy report --summary +``` - `--test-case strings` (alias: `--tc`) - Filter output to specific test case IDs. - ```bash - keploy report --test-case "test-1" - ``` +```bash +keploy report --test-case "test-1" +``` > **Notes** > @@ -401,17 +438,17 @@ keploy config [flags] - `--generate` - Generate a new keploy configration file. - ```bash - keploy config --generate - ``` +```bash +keploy config --generate +``` - `-p, --path string` - Path to the local directory where the Keploy Configuration File will be stored. The default is ".". - ```bash - keploy config --generate --path "./config-dir/" - ``` +```bash +keploy config --generate --path "./config-dir/" +``` - In the above command, `config-dir` is the directory in the CWD where the Keploy configuration file `keploy.yaml` is to be stored. +In the above command, `config-dir` is the directory in the CWD where the Keploy configuration file `keploy.yaml` is to be stored. ## [example](#example)