diff --git a/versioned_docs/version-4.0.0/quickstart/csharp-dotnet-postgres.md b/versioned_docs/version-4.0.0/quickstart/csharp-dotnet-postgres.md index 6b3c0eef8..d2c62b1be 100644 --- a/versioned_docs/version-4.0.0/quickstart/csharp-dotnet-postgres.md +++ b/versioned_docs/version-4.0.0/quickstart/csharp-dotnet-postgres.md @@ -69,10 +69,20 @@ This section runs on Linux or WSL. On macOS, run it inside a [Lima VM](/docs/ins ### Clone a sample user authentication app πŸ§ͺ ```bash -git clone https://github.com/keploy/samples-csharp.git && cd samples-csharp +git clone https://github.com/keploy/samples-csharp.git && cd samples-csharp/crud-app ``` +### Prerequisites + +- Install the [.NET 8 SDK](https://dotnet.microsoft.com/download/dotnet/8.0). +- Install the EF Core tool, using version 8 to match the project (the latest `dotnet-ef` does not work with the .NET 8 SDK): + +```bash +dotnet tool install --global dotnet-ef --version "8.*" +export PATH="$PATH:$HOME/.dotnet/tools" +``` + ### start the database instance ```bash @@ -83,10 +93,9 @@ We'll be running our sample application right on Linux, but just to make things ### πŸ“Ό Roll the Tape - Recording Time! -We need to run the migration command before starting our application: +The project already ships an `InitialMigration`, so we only need to apply it before starting our application: ```bash -dotnet ef migrations add InitialMigration dotnet ef database update ``` diff --git a/versioned_docs/version-4.0.0/quickstart/express-postgresql-prisma.md b/versioned_docs/version-4.0.0/quickstart/express-postgresql-prisma.md index 816f4fcac..db1cec71c 100644 --- a/versioned_docs/version-4.0.0/quickstart/express-postgresql-prisma.md +++ b/versioned_docs/version-4.0.0/quickstart/express-postgresql-prisma.md @@ -206,7 +206,7 @@ Server is listening at PORT 3000 API Docs: http://localhost:3000/api/docs ``` -The above command will start recording the API calls made to the application and will generate a test case in the `testcases/` directory. +The above command will start recording the API calls made to the application and will generate a test case in the `keploy/` directory. > πŸ’‘ You can use Postman or any other API testing tool to test the API calls. Additionally, the application will run a swagger UI on `http://localhost:3000/api/docs` to visualize the API calls. @@ -253,10 +253,10 @@ npm install cp .env.example .env ``` -We will be using Docker compose to run the application as well as PostreSql on Docker container. +We will be using Docker compose to run the application as well as PostgreSQL on Docker container. Lights, Camera, Record! πŸŽ₯ -Fire up the application and mongoDB instance with Keploy. Keep an eye on the two key flags: -c: Command to run the app (e.g., docker compose up). +Fire up the application and PostgreSQL instance with Keploy. Keep an eye on the two key flags: -c: Command to run the app (e.g., docker compose up). --container-name: The container name in the docker-compose.yml for traffic interception. @@ -378,7 +378,7 @@ Using `curl` ```bash curl -X 'PUT' \ - 'http://localhost:3000/api/v1/task/update/2' \ + 'http://localhost:3000/api/v1/task/update/1' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d '{ @@ -424,24 +424,22 @@ Node.js v22.7.0 <=========================================> COMPLETE TESTRUN SUMMARY. - Total tests: 7 - Total test passed: 7 + Total tests: 6 + Total test passed: 6 Total test failed: 0 Total time taken: "5.66 s" Test Suite Name Total Test Passed Failed Time Taken - "test-set-0" 7 7 0 "5.66 s" + "test-set-0" 6 6 0 "5.66 s" <=========================================> -🐰 Keploy: 2024-08-28T10:14:14+05:30 INFO calculating coverage for the test run and inserting it into the report -🐰 Keploy: 2024-08-28T10:14:14+05:30 INFO [Total Coverage Percentage: 86.16%] 🐰 Keploy: 2024-08-28T10:14:14+05:30 INFO stopping Keploy {"reason": "replay completed successfully"} 🐰 Keploy: 2024-08-28T10:14:14+05:30 INFO proxy stopped... 🐰 Keploy: 2024-08-28T10:14:17+05:30 INFO eBPF resources released successfully... ``` -Voila! πŸŽ‰ You have successfully tested the application using Keploy. Keploy also generates coverage reports for the test-suites. +Voila! πŸŽ‰ You have successfully tested the application using Keploy. ## Related diff --git a/versioned_docs/version-4.0.0/quickstart/flask-redis.md b/versioned_docs/version-4.0.0/quickstart/flask-redis.md index 5a4b2d87f..df879fc1b 100644 --- a/versioned_docs/version-4.0.0/quickstart/flask-redis.md +++ b/versioned_docs/version-4.0.0/quickstart/flask-redis.md @@ -75,14 +75,24 @@ git clone https://github.com/keploy/samples-python.git && cd samples-python/flas ## Using Docker Compose 🐳 -We will be using Docker compose to run the application as well as Mongo on Docker container. +We will be using Docker compose to run the application as well as Redis on Docker container. ### Lights, Camera, Record! πŸŽ₯ +:::note macOS +Port `5000` is used by the AirPlay Receiver on macOS, so the app fails to start with `address already in use`. Turn it off under **System Settings β†’ General β†’ AirDrop & Continuity β†’ AirPlay Receiver** before recording. +::: + +The `docker-compose.yml` attaches the services to an external `keploy-network`, so create it once: + +```bash +docker network create keploy-network +``` + Capture the test-cases- ```shell -keploy record -c "docker compose up" --container-name "flask-web" --buildDelay 50 +keploy record -c "docker compose up" --container-name "flask-web" --build-delay 50 ``` πŸ”₯**Make some API calls**. Postman, Hoppscotch or even curl - take your pick! @@ -148,7 +158,7 @@ spec: ### **Time to run the testcases** ```bash -keploy test -c 'sudo docker compose up' --containerName "flask-web" --delay 10 +keploy test -c 'docker compose up' --container-name "flask-web" --delay 10 ``` You can also check the test summary from your cli diff --git a/versioned_docs/version-4.0.0/quickstart/go-gin-redis.md b/versioned_docs/version-4.0.0/quickstart/go-gin-redis.md index 1ad3a5727..d083b0256 100644 --- a/versioned_docs/version-4.0.0/quickstart/go-gin-redis.md +++ b/versioned_docs/version-4.0.0/quickstart/go-gin-redis.md @@ -83,6 +83,8 @@ Start the Redis instance using the `docker-compose` file- docker compose up redis ``` +Since the application runs in a container, `localhost` would point to the container itself. In `helpers/redis/redisConnect.go`, change `Addr: "localhost:6379"` to `Addr: "myredis:6379"`. + Now, we will create the docker image of our application:- ```bash @@ -92,7 +94,7 @@ docker build -t gin-app:1.0 . ### Capture the test-cases- ```shell -keploy record -c "docker run -p 3001:3001 --network --name ginRedisApp gin-app:1.0" +keploy record -c "docker run -p 3001:3001 --network gin-redis_default --name ginRedisApp gin-app:1.0" ``` πŸ”₯**Make some API calls**. Postman, Hoppscotch or even curl - take your pick! @@ -248,8 +250,12 @@ Want to see if everything works as expected? Time to put things to the test πŸ§ͺ +:::note +The OTP changes on every request, so mark it as noise before replaying. Add `body.otp` under `assertions.noise` in the recorded OTP test (the `GET` test in `keploy/test-set-0/tests/`). +::: + ```bash -keploy test -c "docker run -p 3001:3001 --rm --network --name ginRedisApp gin-app:1.0" --delay 10 +keploy test -c "docker run -p 3001:3001 --rm --network gin-redis_default --name ginRedisApp gin-app:1.0" --delay 10 ``` > The `--delay` flag? Oh, that's just giving your app a little breather (in seconds) before the test cases come knocking. @@ -461,6 +467,10 @@ Want to see if everything works as expected? Time to put things to the test πŸ§ͺ +:::note +The OTP changes on every request, so mark it as noise before replaying. Add `body.otp` under `assertions.noise` in the recorded OTP test (the `GET` test in `keploy/test-set-0/tests/`). +::: + ```shell sudo -E env PATH="$PATH" keploy test -c "./gin-redis" --delay 10 ``` diff --git a/versioned_docs/version-4.0.0/quickstart/go-mux-mysql.md b/versioned_docs/version-4.0.0/quickstart/go-mux-mysql.md index 9af50c52e..05ca3fe5b 100644 --- a/versioned_docs/version-4.0.0/quickstart/go-mux-mysql.md +++ b/versioned_docs/version-4.0.0/quickstart/go-mux-mysql.md @@ -76,10 +76,18 @@ We will be using Docker compose to run the application as well as MySQL on Docke ### Start MySQL Instance +Create the `keploy-network` Docker network that both containers use: + +```bash +docker network create keploy-network +``` + ```bash docker run -p 3306:3306 --rm --name mysql --network keploy-network -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:latest ``` +MySQL can take a while to start on its first run. Wait until `docker logs mysql` shows `ready for connections` with `port: 3306` (the earlier `port: 0` line is MySQL's temporary init server) before moving on. + ### Capture the Testcases Build the Docker image of our application: @@ -111,7 +119,7 @@ curl --request POST \ }' ``` -this will return the shortened url. The ts would automatically be ignored during testing because it'll always be different. +this will return the shortened url. ```bash { diff --git a/versioned_docs/version-4.0.0/quickstart/go-mux-sql.md b/versioned_docs/version-4.0.0/quickstart/go-mux-sql.md index d316ade4c..345229f47 100644 --- a/versioned_docs/version-4.0.0/quickstart/go-mux-sql.md +++ b/versioned_docs/version-4.0.0/quickstart/go-mux-sql.md @@ -72,8 +72,18 @@ git clone https://github.com/keploy/samples-go.git && cd samples-go/mux-sql go mod download ``` +#### First things first, update the postgres host in main.go to postgres from localhost. + +The application runs in a container, where `localhost` does not reach the Postgres container. In `main.go`, change the host `"localhost"` to `"postgres"`. + ### Lights, Camera, Record! πŸŽ₯ +The `docker-compose.yml` attaches both services to an external `keploy-network`, so create it once: + +```bash +docker network create keploy-network +``` + Fire up the application and Postgres instance with Keploy. Keep an eye on the two key flags: `-c`: Command to run the app (e.g., `docker compose up`). @@ -263,13 +273,16 @@ go mod download We'll be running our sample application right on Linux, but just to make things a tad more thrilling, we'll have the database (Postgres) chill on Docker. Ready? Let's get the party started!πŸŽ‰ -First things first, update the postgres host on **line 10** in `main.go` to `localhost`. +First things first, update the postgres host on **line 18** in `main.go` to `localhost`. #### πŸƒ Kickstart PostgresDB Let's breathe life into your Postgres container. A simple spell should do the trick: +The `docker-compose.yml` attaches the services to an external `keploy-network`, so create it once. + ```bash +docker network create keploy-network docker compose up postgres ``` diff --git a/versioned_docs/version-4.0.0/quickstart/java-spring-boot-openhospital.md b/versioned_docs/version-4.0.0/quickstart/java-spring-boot-openhospital.md index 858f75857..0a8f59562 100644 --- a/versioned_docs/version-4.0.0/quickstart/java-spring-boot-openhospital.md +++ b/versioned_docs/version-4.0.0/quickstart/java-spring-boot-openhospital.md @@ -83,7 +83,7 @@ mvn clean install -DskipTests=true docker compose up ``` -Note: If you face any issues while setting up the database, please try running docker compose up again. The issue should not occur the second time. +Note: `docker compose up` keeps running in the foreground, so run it in its own terminal (or add `-d`) and continue the next steps in another one. If the first run fails while the database is being initialised (for example with `ERROR 1064` from MySQL), run `docker compose up` again. The issue should not occur the second time. ## Setup the Backend @@ -137,6 +137,8 @@ Now you can start interacting with the UI and Keploy will automatically create t ## Running the testcases using Keploy +Stop the recording with `Ctrl+C` first. The database and the UI do not need to be running for `keploy test`, as Keploy replays the recorded mocks. + ```bash keploy test -c "java -cp "target/openhospital-api-0.1.0.jar:rsc/:static/" org.springframework.boot.loader.launch.JarLauncher" --delay 40 diff --git a/versioned_docs/version-4.0.0/quickstart/java-spring-boot-xml.md b/versioned_docs/version-4.0.0/quickstart/java-spring-boot-xml.md index 71dd4e719..f47c6e280 100644 --- a/versioned_docs/version-4.0.0/quickstart/java-spring-boot-xml.md +++ b/versioned_docs/version-4.0.0/quickstart/java-spring-boot-xml.md @@ -80,7 +80,7 @@ This runs natively on Linux, macOS (Apple Silicon) and Windows (x86-64) β€” see ```bash git clone https://github.com/keploy/samples-java.git -cd spring-boot-xml/naive-spring-boot +cd samples-java/spring-boot-xml/naive-spring-boot mvn clean install ``` @@ -92,6 +92,8 @@ Start the Spring Boot application with: mvn spring-boot:run ``` +Once you have confirmed the application starts, stop it (`Ctrl+C`) so that port `8080` is free for Keploy to record on. + ### Record Test Cases ```bash @@ -111,7 +113,7 @@ Then, invoke the API using `curl` or your favorite API testing tool. Make a request using `curl`: ```bash -curl -X GET -H \"Accept: application/xml\" http://localhost:8080/api/user +curl -X GET -H "Accept: application/xml" http://localhost:8080/api/user ``` - **Endpoint**: `GET /api/users` @@ -148,7 +150,11 @@ Execute recorded tests: keploy test -c "java -jar target/XML-0.0.1-SNAPSHOT.jar" --delay 10 ``` -Review generated test reports in `Keploy/reports`. +Review generated test reports in `keploy/reports`. + +:::note +No `mocks.yaml` is created for this sample: the app makes no outbound calls (no database or external API), so there is nothing to mock. That is expected. +::: ## Handling Failing Tests ⚠️ diff --git a/versioned_docs/version-4.0.0/quickstart/java-spring-postgres.md b/versioned_docs/version-4.0.0/quickstart/java-spring-postgres.md index 200a37e65..c3b605a5c 100644 --- a/versioned_docs/version-4.0.0/quickstart/java-spring-postgres.md +++ b/versioned_docs/version-4.0.0/quickstart/java-spring-postgres.md @@ -141,7 +141,7 @@ keploy record -c "java -jar target/spring-petclinic-rest-3.0.2.jar" Sample Keploy Test Result Node JWT -Now you can start interacting with the UI and Keploy will automatically create the testcases and mocks for it in a folder named 'keploy'. +Now you can start interacting with the UI and Keploy will automatically create the testcases and mocks for it in a folder named 'keploy'. The database starts empty, so create a pet type under **Pet Types** first, then add an owner and a pet; the lists stay empty until you do. ## Running the testcases using Keploy @@ -192,12 +192,20 @@ Prerequisites For API backend Binary: ## Recording the testcases with Keploy +The `docker-compose.yaml` of this sample attaches both services to an external `keploy-network`, so create it once before recording: + +```bash +docker network create keploy-network +``` + ```bash keploy record -c "docker compose up" --container-name javaApp --build-delay 100 ``` Sample Keploy Record Java +Once the backend is running under Keploy, start interacting with the UI. The database starts empty, so create a pet type under **Pet Types** first, then add an owner and a pet; the lists stay empty until you do. + ## Running the testcases using Keploy ```bash diff --git a/versioned_docs/version-4.0.0/quickstart/node-jwt-sql.md b/versioned_docs/version-4.0.0/quickstart/node-jwt-sql.md index 8ff5faf57..4d14a9677 100644 --- a/versioned_docs/version-4.0.0/quickstart/node-jwt-sql.md +++ b/versioned_docs/version-4.0.0/quickstart/node-jwt-sql.md @@ -67,7 +67,7 @@ This section runs on Linux or WSL. On macOS, or on Windows without WSL, use the ### Setup application -Clone the repository and move to express-mongo folder +Clone the repository and move to node-jwt folder ```bash git clone https://github.com/keploy/samples-typescript && cd samples-typescript/node-jwt @@ -87,7 +87,8 @@ wsl ~ ### Let's start the Postgres Instance ```zsh -docker-compose up -d +docker network create keploy-network +docker compose up -d postgres ``` ## Capture the testcases @@ -178,7 +179,7 @@ curl --location 'http://localhost:8080/api/test/all' We will get: ``` -Public Content +Public Content. ``` 5. Access user Content @@ -188,10 +189,12 @@ curl --location 'http://localhost:8080/api/test/user' \ --header 'x-access-token: ' ``` +Replace `` with the `accessToken` returned by the sign-in response in step 3. The token expires 35 seconds after sign-in, so send this request within that window (or sign in again first), otherwise the app answers `401` with `Unauthorized!`. + We will get ``` -User Content +User Content. ``` ## Running the testcases @@ -200,12 +203,11 @@ User Content sudo -E env PATH=$PATH keploy test -c 'node app.js' --delay 10 ``` -Our testcases will fail as the token would expire and new Token will generated again when we are using testmode. To make sure that testcases do not fail, we have use [timeFreezing](https://keploy.io/docs/keploy-cloud/time-freezing/). Our testcases will fail as the token would expire and new Token will generated again when we are using testmode. To make sure that testcases do not fail, we have use [timeFreezing](https://keploy.io/docs/keploy-cloud/time-freezing/). Sample Keploy Test Result Node JWT -But for this application, the Token expiration is 10 mins so let's go ahead and test the application within 10 mins. Let's add the `Etag` and `accessToken` as the noise in the `keploy.yml` on line 21 under `globalNoise`. The file would look like:- +But for this application, the Token expiration is 35 seconds. Let's add the `Etag` and `accessToken` as the noise in the `keploy.yml` on line 21 under `globalNoise`. The file would look like:- ``` globalNoise: @@ -244,7 +246,7 @@ A simple sample CRUD application to test using Keploy build with Node, JWT and P ### Setup application -Clone the repository and move to express-mongo folder +Clone the repository and move to node-jwt folder ```bash git clone https://github.com/keploy/samples-typescript && cd samples-typescript/node-jwt @@ -259,6 +261,12 @@ Since we have setup our sample-app using docker, we need to update the postgres ## Capture the testcases +The `docker-compose.yml` attaches the services to an external `keploy-network`, so create it once before recording: + +```bash +docker network create keploy-network +``` + We will run the keploy in record mode with docker-compose to start our application:- ```bash @@ -347,7 +355,7 @@ curl --location 'http://localhost:8080/api/test/all' We will get: ``` -Public Content +Public Content. ``` 5. Access user Content @@ -357,10 +365,12 @@ curl --location 'http://localhost:8080/api/test/user' \ --header 'x-access-token: ' ``` +Replace `` with the `accessToken` returned by the sign-in response in step 3. The token expires 35 seconds after sign-in, so send this request within that window (or sign in again first), otherwise the app answers `401` with `Unauthorized!`. + We will get ``` -User Content +User Content. ``` ## Running the testcases @@ -373,7 +383,7 @@ Our testcases will fail as the token would expire and new Token will generated a Sample Keploy Test Result Node JWT -But for this application, the Token expiration is 10 mins so let's go ahead and test the application within 10 mins. Let's add the `Etag` and `accessToken` as the noise in the `keploy.yml` on line 21 under `globalNoise`. The file would look like:- +But for this application, the Token expiration is 35 seconds. Let's add the `Etag` and `accessToken` as the noise in the `keploy.yml` on line 21 under `globalNoise`. The file would look like:- ``` globalNoise: diff --git a/versioned_docs/version-4.0.0/quickstart/python-django-sql.md b/versioned_docs/version-4.0.0/quickstart/python-django-sql.md index 13833a232..6fc4258a9 100644 --- a/versioned_docs/version-4.0.0/quickstart/python-django-sql.md +++ b/versioned_docs/version-4.0.0/quickstart/python-django-sql.md @@ -72,18 +72,30 @@ import ProductTier from '@site/src/components/ProductTier'; git clone https://github.com/keploy/samples-python.git && cd samples-python/django-postgres/django_postgres ``` -We will be using Docker compose to run the application as well as Postgres on Docker container. +We will be using Docker compose to run Postgres and Docker to run the application. ### Lights, Camera, Record! πŸŽ₯ #### Start Postgres Instance +Create the `keploy-network` Docker network that the containers use: + +```bash +docker network create keploy-network +``` + Start the Postgres instance using the `docker-compose` file- ```bash docker compose up -d postgres ``` +The compose file does not join `keploy-network` or name the container `mypostgres` (the host `settings.py` uses below), so attach it with that alias: + +```bash +docker network connect --alias mypostgres keploy-network $(docker compose ps -q postgres) +``` + Change the database configuration in `django_postgres/settings.py` file to: ```python @@ -105,6 +117,12 @@ Build the app image: docker build -t django-app:1.0 . ``` +The Dockerfile only runs `runserver` and `sql/init.sql` creates no tables, so apply the migrations once: + +```bash +docker run --rm --network keploy-network django-app:1.0 python manage.py migrate +``` + Capture the test-cases- ```shell @@ -140,8 +158,10 @@ curl --location 'http://127.0.0.1:8000/user/' **3. Make a PUT request** +Replace `` here and in the next two requests with the `id` returned by the `GET /user/` call above. + ```bash -curl --location --request PUT 'http://127.0.0.1:8000/user/' \ +curl --location --request PUT 'http://127.0.0.1:8000/user//' \ --header 'Content-Type: application/json' \ --data-raw ' { "name": "Jane Smith", @@ -154,13 +174,13 @@ curl --location --request PUT 'http://127.0.0.1:8000/user/' \ **4. Make a GET request** ```bash -curl --location 'http://127.0.0.1:8000/user/' +curl --location 'http://127.0.0.1:8000/user//' ``` **5. Make a DELETE request** ```bash - curl --location --request DELETE 'http://127.0.0.1:8000/user/' + curl --location --request DELETE 'http://127.0.0.1:8000/user//' ``` Give yourself a pat on the back! With that simple spell, you've conjured up a test case with a mock! Explore the **Keploy directory** and you'll discover your handiwork in `test-1.yml` and `mocks.yml`. @@ -360,8 +380,10 @@ curl --location 'http://127.0.0.1:8000/user/' **3. Make a PUT request** +Replace `` here and in the next two requests with the `id` returned by the `GET /user/` call above. + ```bash -curl --location --request PUT 'http://127.0.0.1:8000/user/' \ +curl --location --request PUT 'http://127.0.0.1:8000/user//' \ --header 'Content-Type: application/json' \ --data-raw ' { "name": "Jane Smith", @@ -374,13 +396,13 @@ curl --location --request PUT 'http://127.0.0.1:8000/user/' \ **4. Make a GET request** ```bash -curl --location 'http://127.0.0.1:8000/user/' +curl --location 'http://127.0.0.1:8000/user//' ``` **5. Make a DELETE request** ```bash - curl --location --request DELETE 'http://127.0.0.1:8000/user/' + curl --location --request DELETE 'http://127.0.0.1:8000/user//' ``` Give yourself a pat on the back! With that simple spell, you've conjured up a test case with a mock! Explore the **Keploy directory** and you'll discover your handiwork in `test-1.yml` and `mocks.yml`. diff --git a/versioned_docs/version-4.0.0/quickstart/python-fastapi-sql.md b/versioned_docs/version-4.0.0/quickstart/python-fastapi-sql.md index 930b484ed..254270917 100644 --- a/versioned_docs/version-4.0.0/quickstart/python-fastapi-sql.md +++ b/versioned_docs/version-4.0.0/quickstart/python-fastapi-sql.md @@ -73,8 +73,18 @@ import ProductTier from '@site/src/components/ProductTier'; git clone https://github.com/keploy/samples-python.git && cd samples-python/fastapi-postgres ``` +### Point the app at the Postgres container πŸ”Œ + +The app runs in a container, so it must reach Postgres by its compose service name instead of `localhost`. In both `application/main.py` and `application/database.py`, change `@localhost:5432` to `@postgres:5432` in `SQLALCHEMY_DATABASE_URL`. + ### Lights, Camera, Record! πŸŽ₯ +The `docker-compose.yml` attaches the services to an external `keploy-network`, so create it once: + +```bash +docker network create keploy-network +``` + Capture the test-cases- ```shell @@ -132,12 +142,12 @@ curl --location 'http://127.0.0.1:8000/students/1' curl --location --request DELETE 'http://127.0.0.1:8000/students/1' ``` -Give yourself a pat on the back! With that simple spell, you've conjured up a test case with a mock! Explore the **Keploy directory** and you'll discover your handiwork in `test-1.yml` and `mocks.yml`. +Give yourself a pat on the back! With that simple spell, you've conjured up a test case with a mock! Explore the **Keploy directory** and you'll discover your handiwork in `keploy/test-set-0/tests/` (one file per call, e.g. `post-students-1.yaml`) and `keploy/test-set-0/mocks.yaml`. ```yaml -version: api.keploy.io/v1beta2 +version: api.keploy.io/v1beta1 kind: Http -name: test-1 +name: get-students-1 spec: metadata: {} req: @@ -148,79 +158,107 @@ spec: header: Accept: "*/*" Host: 127.0.0.1:8000 - User-Agent: curl/7.81.0 + User-Agent: curl/8.7.1 body: "" - body_type: "" - timestamp: 2023-11-06T10:42:43.046337785+05:30 + timestamp: 2026-11-16T12:37:17.039514963Z resp: - status_code: 404 + status_code: 200 header: - Content-Length: "29" + Content-Length: "109" Content-Type: application/json - Date: Mon, 06 Nov 2023 05:12:42 GMT + Date: Mon, 16 Nov 2026 12:37:16 GMT Server: uvicorn - body: '{"detail":"Data not found!!"}' - body_type: "" - status_message: "" + body: '[{"name":"Eva White","email":"evawhite@example.com","password":"sfwbxijuf222","stream":"Mathematics","id":1}]' + status_message: OK proto_major: 0 proto_minor: 0 - timestamp: 2023-11-06T10:42:45.959907593+05:30 + timestamp: 2026-11-16T12:37:17.044762963Z objects: [] assertions: noise: - - header.Date - created: 1699247565 + header.Date: [] + created: 1794832637 + app_port: 8000 curl: | curl --request GET \ - --url http://127.0.0.1:8000/students/ \ - --header 'User-Agent: curl/7.81.0' \ - --header 'Accept: */*' \ - --header 'Host: 127.0.0.1:8000' \ + --url http://127.0.0.1:8000/students/ \ + --header 'Accept: */*' \ + --header 'Host: 127.0.0.1:8000' \ + --header 'User-Agent: curl/8.7.1' \ ``` -This is how `mocks.yml` generated would look like:- +This is how the generated `mocks.yaml` would look like:- ```yaml - version: api.keploy.io/v1beta2 - kind: Postgres - name: mocks - spec: - metadata: {} - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - query: - string: SELECT students."ID" AS "students_ID", students."Name" AS "students_Name", students."Email" AS "students_Email", students."Hashed Password" AS "students_Hashed Password", students."Subject Stream" AS "students_Subject Stream" FROM students LIMIT 100 OFFSET 0 - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [T, C, Z] - identifier: ServerResponse - length: 8 - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 83 - - 69 - - 76 - - 69 - - 67 - - 84 - - 32 - - 48 - ready_for_query: - txstatus: 84 - row_description: {fields: [{name: [115, 116, 117, 100, 101, 110, 116, 115, 95, 73, 68], table_oid: 24577, table_attribute_number: 1, data_type_oid: 23, data_type_size: 4, type_modifier: -1, format: 0}, {name: [115, 116, 117, 100, 101, 110, 116, 115, 95, 78, 97, 109, 101], table_oid: 24577, table_attribute_number: 2, data_type_oid: 1043, data_type_size: -1, type_modifier: -1, format: 0}, {name: [115, 116, 117, 100, 101, 110, 116, 115, 95, 69, 109, 97, 105, 108], table_oid: 24577, table_attribute_number: 3, data_type_oid: 1043, data_type_size: -1, type_modifier: -1, format: 0}, {name: [115, 116, 117, 100, 101, 110, 116, 115, 95, 72, 97, 115, 104, 101, 100, 32, 80, 97, 115, 115, 119, 111, 114, 100], table_oid: 24577, table_attribute_number: 4, data_type_oid: 1043, data_type_size: -1, type_modifier: -1, format: 0}, {name: [115, 116, 117, 100, 101, 110, 116, 115, 95, 83, 117, 98, 106, 101, 99, 116, 32, 83, 116, 114, 101, 97, 109], table_oid: 24577, table_attribute_number: 5, data_type_oid: 1043, data_type_size: -1, type_modifier: -1, format: 0}]} - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2023-11-06T10:42:43.063446464+05:30 - restimestampmock: 2023-11-06T10:42:43.063544657+05:30 +version: api.keploy.io/v1beta1 +kind: PostgresV3 +name: mock-28 +spec: + metadata: + bindEncoding: wire + class: APP + connID: "2" + destAddr: 172.21.0.2:5432 + lifetime: perTest + type: mocks + postgresV3: + type: query + query: + class: APP + lifetime: perTest + sqlAstHash: sha256:c7ada4e1d75ca3577e3832dabf1d290a894d7a9b47164ad99cc809a9f0384b30 + sqlNormalized: "SELECT students.\"ID\" AS \"students_ID\", students.\"Name\" AS \"students_Name\", students.\"Email\" AS \"students_Email\", students.\"Hashed Password\" AS \"students_Hashed Password\", students.\"Subject Stream\" AS \"students_Subject Stream\" \nFROM students \n LIMIT $2 OFFSET $1" + invocationId: sha256:c7ada4e1d75ca3577e3832dabf1d290a894d7a9b47164ad99cc809a9f0384b30:2:2026-11-16T12:37:17.042651505Z:24 + precedingTxState: in_tx + bindValues: + - !!binary MTAw + - !!binary MA== + bindFormats: + - 0 + - 0 + response: + rowDescription: + - name: students_ID + tableOid: 16386 + colAttrNum: 1 + typeOid: 23 + typeSize: 4 + typeMod: -1 + - name: students_Name + tableOid: 16386 + colAttrNum: 2 + typeOid: 1043 + typeSize: -1 + typeMod: -1 + - name: students_Email + tableOid: 16386 + colAttrNum: 3 + typeOid: 1043 + typeSize: -1 + typeMod: -1 + - name: students_Hashed Password + tableOid: 16386 + colAttrNum: 4 + typeOid: 1043 + typeSize: -1 + typeMod: -1 + - name: students_Subject Stream + tableOid: 16386 + colAttrNum: 5 + typeOid: 1043 + typeSize: -1 + typeMod: -1 + rows: + - - 1 + - Eva White + - evawhite@example.com + - sfwbxijuf222 + - Mathematics + commandComplete: SELECT 1 + sideEffects: {} + reqTimestampMock: 2026-11-16T12:37:17.042651505Z + resTimestampMock: 2026-11-16T12:37:17.043078546Z +connectionId: "2" ``` Want to see if everything works as expected? @@ -235,7 +273,7 @@ keploy test -c "docker compose up" --container-name "fastapi-app" --build-delay > The `--delay` flag? Oh, that's just giving your app a little breather (in seconds) before the test cases come knocking. -Final thoughts? Dive deeper! Try different API calls, tweak the DB response in the `mocks.yml`, or fiddle with the request or response in `test-x.yml`. Run the tests again and see the magic unfold!βœ¨πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»βœ¨ +Final thoughts? Dive deeper! Try different API calls, tweak the DB response in the `mocks.yaml`, or fiddle with the request or response in the files under `tests/`. Run the tests again and see the magic unfold!βœ¨πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»βœ¨ ### Wrapping it up πŸŽ‰ @@ -261,6 +299,15 @@ This section runs on Linux or WSL. On macOS, or on Windows without WSL, use the git clone https://github.com/keploy/samples-python.git && cd samples-python/fastapi-postgres ``` +### Start the Postgres instance 🐘 + +The app connects to `localhost:5432/studentdb`, so start the database first. The compose file attaches it to an external `keploy-network`, so create that once: + +```bash +docker network create keploy-network +docker compose up -d postgres +``` + ### Lights, Camera, Record! πŸŽ₯ Capture the test-cases- @@ -320,12 +367,12 @@ curl --location 'http://127.0.0.1:8000/students/1' curl --location --request DELETE 'http://127.0.0.1:8000/students/1' ``` -Give yourself a pat on the back! With that simple spell, you've conjured up a test case with a mock! Explore the **Keploy directory** and you'll discover your handiwork in `test-1.yml` and `mocks.yml`. +Give yourself a pat on the back! With that simple spell, you've conjured up a test case with a mock! Explore the **Keploy directory** and you'll discover your handiwork in `keploy/test-set-0/tests/` (one file per call, e.g. `post-students-1.yaml`) and `keploy/test-set-0/mocks.yaml`. ```yaml -version: api.keploy.io/v1beta2 +version: api.keploy.io/v1beta1 kind: Http -name: test-1 +name: get-students-1 spec: metadata: {} req: @@ -336,79 +383,107 @@ spec: header: Accept: "*/*" Host: 127.0.0.1:8000 - User-Agent: curl/7.81.0 + User-Agent: curl/8.7.1 body: "" - body_type: "" - timestamp: 2023-11-06T10:42:43.046337785+05:30 + timestamp: 2026-11-16T12:37:17.039514963Z resp: - status_code: 404 + status_code: 200 header: - Content-Length: "29" + Content-Length: "109" Content-Type: application/json - Date: Mon, 06 Nov 2023 05:12:42 GMT + Date: Mon, 16 Nov 2026 12:37:16 GMT Server: uvicorn - body: '{"detail":"Data not found!!"}' - body_type: "" - status_message: "" + body: '[{"name":"Eva White","email":"evawhite@example.com","password":"sfwbxijuf222","stream":"Mathematics","id":1}]' + status_message: OK proto_major: 0 proto_minor: 0 - timestamp: 2023-11-06T10:42:45.959907593+05:30 + timestamp: 2026-11-16T12:37:17.044762963Z objects: [] assertions: noise: - - header.Date - created: 1699247565 + header.Date: [] + created: 1794832637 + app_port: 8000 curl: | curl --request GET \ - --url http://127.0.0.1:8000/students/ \ - --header 'User-Agent: curl/7.81.0' \ - --header 'Accept: */*' \ - --header 'Host: 127.0.0.1:8000' \ + --url http://127.0.0.1:8000/students/ \ + --header 'Accept: */*' \ + --header 'Host: 127.0.0.1:8000' \ + --header 'User-Agent: curl/8.7.1' \ ``` -This is how `mocks.yml` generated would look like:- +This is how the generated `mocks.yaml` would look like:- ```yaml - version: api.keploy.io/v1beta2 - kind: Postgres - name: mocks - spec: - metadata: {} - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - query: - string: SELECT students."ID" AS "students_ID", students."Name" AS "students_Name", students."Email" AS "students_Email", students."Hashed Password" AS "students_Hashed Password", students."Subject Stream" AS "students_Subject Stream" FROM students LIMIT 100 OFFSET 0 - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [T, C, Z] - identifier: ServerResponse - length: 8 - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 83 - - 69 - - 76 - - 69 - - 67 - - 84 - - 32 - - 48 - ready_for_query: - txstatus: 84 - row_description: {fields: [{name: [115, 116, 117, 100, 101, 110, 116, 115, 95, 73, 68], table_oid: 24577, table_attribute_number: 1, data_type_oid: 23, data_type_size: 4, type_modifier: -1, format: 0}, {name: [115, 116, 117, 100, 101, 110, 116, 115, 95, 78, 97, 109, 101], table_oid: 24577, table_attribute_number: 2, data_type_oid: 1043, data_type_size: -1, type_modifier: -1, format: 0}, {name: [115, 116, 117, 100, 101, 110, 116, 115, 95, 69, 109, 97, 105, 108], table_oid: 24577, table_attribute_number: 3, data_type_oid: 1043, data_type_size: -1, type_modifier: -1, format: 0}, {name: [115, 116, 117, 100, 101, 110, 116, 115, 95, 72, 97, 115, 104, 101, 100, 32, 80, 97, 115, 115, 119, 111, 114, 100], table_oid: 24577, table_attribute_number: 4, data_type_oid: 1043, data_type_size: -1, type_modifier: -1, format: 0}, {name: [115, 116, 117, 100, 101, 110, 116, 115, 95, 83, 117, 98, 106, 101, 99, 116, 32, 83, 116, 114, 101, 97, 109], table_oid: 24577, table_attribute_number: 5, data_type_oid: 1043, data_type_size: -1, type_modifier: -1, format: 0}]} - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2023-11-06T10:42:43.063446464+05:30 - restimestampmock: 2023-11-06T10:42:43.063544657+05:30 +version: api.keploy.io/v1beta1 +kind: PostgresV3 +name: mock-28 +spec: + metadata: + bindEncoding: wire + class: APP + connID: "2" + destAddr: 172.21.0.2:5432 + lifetime: perTest + type: mocks + postgresV3: + type: query + query: + class: APP + lifetime: perTest + sqlAstHash: sha256:c7ada4e1d75ca3577e3832dabf1d290a894d7a9b47164ad99cc809a9f0384b30 + sqlNormalized: "SELECT students.\"ID\" AS \"students_ID\", students.\"Name\" AS \"students_Name\", students.\"Email\" AS \"students_Email\", students.\"Hashed Password\" AS \"students_Hashed Password\", students.\"Subject Stream\" AS \"students_Subject Stream\" \nFROM students \n LIMIT $2 OFFSET $1" + invocationId: sha256:c7ada4e1d75ca3577e3832dabf1d290a894d7a9b47164ad99cc809a9f0384b30:2:2026-11-16T12:37:17.042651505Z:24 + precedingTxState: in_tx + bindValues: + - !!binary MTAw + - !!binary MA== + bindFormats: + - 0 + - 0 + response: + rowDescription: + - name: students_ID + tableOid: 16386 + colAttrNum: 1 + typeOid: 23 + typeSize: 4 + typeMod: -1 + - name: students_Name + tableOid: 16386 + colAttrNum: 2 + typeOid: 1043 + typeSize: -1 + typeMod: -1 + - name: students_Email + tableOid: 16386 + colAttrNum: 3 + typeOid: 1043 + typeSize: -1 + typeMod: -1 + - name: students_Hashed Password + tableOid: 16386 + colAttrNum: 4 + typeOid: 1043 + typeSize: -1 + typeMod: -1 + - name: students_Subject Stream + tableOid: 16386 + colAttrNum: 5 + typeOid: 1043 + typeSize: -1 + typeMod: -1 + rows: + - - 1 + - Eva White + - evawhite@example.com + - sfwbxijuf222 + - Mathematics + commandComplete: SELECT 1 + sideEffects: {} + reqTimestampMock: 2026-11-16T12:37:17.042651505Z + resTimestampMock: 2026-11-16T12:37:17.043078546Z +connectionId: "2" ``` Want to see if everything works as expected? @@ -423,7 +498,7 @@ keploy test -c "uvicorn application.main:app --reload" --delay 10 > The `--delay` flag? Oh, that's just giving your app a little breather (in seconds) before the test cases come knocking. -Final thoughts? Dive deeper! Try different API calls, tweak the DB response in the `mocks.yml`, or fiddle with the request or response in `test-x.yml`. Run the tests again and see the magic unfold!βœ¨πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»βœ¨ +Final thoughts? Dive deeper! Try different API calls, tweak the DB response in the `mocks.yaml`, or fiddle with the request or response in the files under `tests/`. Run the tests again and see the magic unfold!βœ¨πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»βœ¨ ### Wrapping it up πŸŽ‰ diff --git a/versioned_docs/version-4.0.0/quickstart/python-fastapi-twilio.md b/versioned_docs/version-4.0.0/quickstart/python-fastapi-twilio.md index d90a0c136..c500a1366 100644 --- a/versioned_docs/version-4.0.0/quickstart/python-fastapi-twilio.md +++ b/versioned_docs/version-4.0.0/quickstart/python-fastapi-twilio.md @@ -71,22 +71,26 @@ import ProductTier from '@site/src/components/ProductTier'; ## Get Started! 🎬 -## Setup the Twilio Account πŸ’¬ - -You can get your Twilio credentials by signing in to Twilio Console. -Once you get the `Twilio Account SID, Auth Token, and Phone Number`, modify the `.env` file with your credentials. - ## Clone the Sample App πŸ§ͺ ```bash git clone https://github.com/keploy/samples-python.git && cd samples-python/fastapi-twilio ``` -We will be using Docker compose to run the application as well as Mongo on Docker container. +We will be using Docker to run the application. + +## Setup the Twilio Account πŸ’¬ + +You can get your Twilio credentials by signing in to Twilio Console. +Once you get the `Twilio Account SID, Auth Token, and Phone Number`, modify the `.env` file with your credentials. ### Lights, Camera, Record! πŸŽ₯ -Create the docker image of the app: +Create the `keploy-network` Docker network and the docker image of the app: + +```bash +docker network create keploy-network +``` ```bash docker build -t fastapi-twilio:1.0 . @@ -115,7 +119,7 @@ To generate testcases we just need to **make some API calls.** --header 'Content-Type: application/json' \ --data '{ "Body": "Test, testtt, testttttttssss :)", - "To": "YOUR_REGISTERED_PERSONAL_PHONE_NUMBER", + "To": "YOUR_REGISTERED_PERSONAL_PHONE_NUMBER" }' ``` @@ -126,7 +130,7 @@ To generate testcases we just need to **make some API calls.** --header 'Content-Type: application/json' \ --data '{ "Body": "Test, testtt, testttttttssss :)", - "To": "SOME_WRONG_PHONE_NUMBER", + "To": "SOME_WRONG_PHONE_NUMBER" }' ``` @@ -283,23 +287,23 @@ This runs natively on Linux, macOS (Apple Silicon) and Windows (x86-64) β€” see +## Clone the Sample App πŸ§ͺ + +```bash +git clone https://github.com/keploy/samples-python.git && cd samples-python/fastapi-twilio +``` + ## Setup the Twilio Account πŸ’¬ You can get your Twilio credentials by signing in to Twilio Console. Once you get the `Twilio Account SID, Auth Token, and Phone Number`, modify the `.env` file with your credentials. -Install the dependencies using the `requirements.txt` file: +Install the dependencies using the `requirements.txt` file (use Python 3.11, as newer versions such as 3.13 cannot build some of the pinned dependencies): ```bash pip3 install -r requirements.txt ``` -## Clone the Sample App πŸ§ͺ - -```bash -git clone https://github.com/keploy/samples-python.git && cd samples-python/fastapi-twilio -``` - ### Lights, Camera, Record! πŸŽ₯ ```bash @@ -325,7 +329,7 @@ To generate testcases we just need to **make some API calls.** --header 'Content-Type: application/json' \ --data '{ "Body": "Test, testtt, testttttttssss :)", - "To": "YOUR_REGISTERED_PERSONAL_PHONE_NUMBER", + "To": "YOUR_REGISTERED_PERSONAL_PHONE_NUMBER" }' ``` @@ -336,7 +340,7 @@ To generate testcases we just need to **make some API calls.** --header 'Content-Type: application/json' \ --data '{ "Body": "Test, testtt, testttttttssss :)", - "To": "SOME_WRONG_PHONE_NUMBER", + "To": "SOME_WRONG_PHONE_NUMBER" }' ``` diff --git a/versioned_docs/version-4.0.0/quickstart/python-microservices.md b/versioned_docs/version-4.0.0/quickstart/python-microservices.md index ec306bcc0..319c3718d 100644 --- a/versioned_docs/version-4.0.0/quickstart/python-microservices.md +++ b/versioned_docs/version-4.0.0/quickstart/python-microservices.md @@ -1343,7 +1343,7 @@ spec: Now, let’s run the tests that were automatically generated by Keploy. Use this command: ```bash -keploy test -c "docker compose up" --containerName="order_service" --delay 30 --path="./order_service" --config-path="./order_service" +keploy test -c "docker compose up" --container-name="order_service" --delay 30 --path="./order_service" --config-path="./order_service" ``` Sample Keploy Record microservices diff --git a/versioned_docs/version-4.0.0/quickstart/sample-ts.md b/versioned_docs/version-4.0.0/quickstart/sample-ts.md index 2aea46873..9a602599a 100644 --- a/versioned_docs/version-4.0.0/quickstart/sample-ts.md +++ b/versioned_docs/version-4.0.0/quickstart/sample-ts.md @@ -91,7 +91,7 @@ Ready to dive in? Let’s make this setup as smooth as a breeze! 🌟 ### Start recording tests: ```bash -sudo -E env "PATH=$PATH" keploy record -c 'ts-node src/app.ts' +sudo -E env "PATH=$PATH" keploy record -c 'npx ts-node src/app.ts' ``` `sudo -E`: Runs the command with elevated privileges while preserving the user environment. @@ -100,9 +100,9 @@ sudo -E env "PATH=$PATH" keploy record -c 'ts-node src/app.ts' `keploy record`: Invokes Keploy in recording mode. -`-c 'ts-node src/app.ts`': Specifies the command to start your application (in this case, using ts-node to execute the TypeScript application entry point). +`-c 'npx ts-node src/app.ts'`: Specifies the command to start your application (in this case, using `npx ts-node` to run the `ts-node` installed in the project's dev dependencies). -`sudo -E env "PATH=$PATH"` is needed on Linux (and WSL) only β€” on macOS and Windows, run `keploy record -c 'ts-node src/app.ts'` here, and `keploy test` below, without it. +`sudo -E env "PATH=$PATH"` is needed on Linux (and WSL) only β€” on macOS and Windows, run `keploy record -c 'npx ts-node src/app.ts'` here, and `keploy test` below, without it. ### Generating the test cases @@ -218,7 +218,7 @@ curl: |- Now, let's put things to test and run the keploy in test mode again:- ```bash -sudo -E env "PATH=$PATH" keploy test -c 'ts-node src/app.ts' --delay 10 +sudo -E env "PATH=$PATH" keploy test -c 'npx ts-node src/app.ts' --delay 10 ``` Voila!! Our test cases have passed 🌟 @@ -268,10 +268,16 @@ We will be using Docker compose to run the application as well as GraphQL on Doc ### Capture the testcases +The `docker-compose.yml` attaches the app to an external `keploy-network`, so create it once: + +```bash +docker network create keploy-network +``` + We will run the keploy in record mode with docker-compose to start our application:- ```bash -keploy record -c "sudo docker compose up" --containerName "ts-nhost" +keploy record -c "docker compose up" --container-name "ts-nhost" ``` Sample Keploy Record TS Nhost @@ -326,7 +332,7 @@ curl --request POST \ Let's run our captured test cases ```bash -keploy test -c 'sudo docker compose up' --containerName "ts-nhost" --delay 10 +keploy test -c 'docker compose up' --container-name "ts-nhost" --delay 10 ``` This is what your response should look like! diff --git a/versioned_docs/version-4.0.0/quickstart/samples-echo.md b/versioned_docs/version-4.0.0/quickstart/samples-echo.md index 07b559a7a..c846407e8 100644 --- a/versioned_docs/version-4.0.0/quickstart/samples-echo.md +++ b/versioned_docs/version-4.0.0/quickstart/samples-echo.md @@ -72,7 +72,7 @@ git clone https://github.com/keploy/samples-go.git && cd samples-go/echo-sql go mod download ``` -#### First things first, update the postgres host on line 41 in main.go to postgres from localhost. +#### First things first, check the postgres host on line 47 in main.go. It is already set to `postgresDb`, the container name (and network alias) of Postgres in `docker-compose.yml`, so no change is needed for Docker. We will be using Docker compose to run the application as well as Postgres @@ -116,6 +116,8 @@ this will return the shortened url. The ts would automatically be ignored during curl http://localhost:8082/GuwHCgoQ ``` +`GuwHCgoQ` is just an example short code; use the one returned in the `url` field of your own response. + 2. Or by querying through the browser `http://localhost:8082/GuwHCgoQ` Now both these API calls were captured as **editable** testcases and written to `keploy/tests` folder. The keploy directory would also have `mocks` file that contains all the outputs of postgres operations. Here's what the folder structure look like: @@ -174,7 +176,7 @@ Using the docker-compose file we will start our Postgres instance:- docker-compose up postgres ``` -> **Since we are using docker to run the application, we need to update the `postgres` host on line 41 in `main.go`, update the host to `localhost`.** +> **Since we are running the application natively, update the `postgresDb` host on line 47 in `main.go` to `localhost`.** Now, we will create the binary of our application:- @@ -220,6 +222,8 @@ curl http://localhost:8082/Lhr4BWAi or by querying through the browser `http://localhost:8082/Lhr4BWAi` +`Lhr4BWAi` is just an example short code; use the one returned in the `url` field of your own response. + Now, let's see the magic! πŸͺ„πŸ’« Now both these API calls were captured as a testcase and should be visible on the Keploy CLI. You should be seeing an app named keploy folder with the test cases we just captured and data mocks created diff --git a/versioned_docs/version-4.0.0/quickstart/samples-java.md b/versioned_docs/version-4.0.0/quickstart/samples-java.md index ee54d06a3..96b646e9f 100644 --- a/versioned_docs/version-4.0.0/quickstart/samples-java.md +++ b/versioned_docs/version-4.0.0/quickstart/samples-java.md @@ -271,6 +271,12 @@ mvn clean install -Dmaven.test.skip=true ### Capture the testcases 🎬 +The `docker-compose.yaml` of this sample attaches both services to an external `keploy-network`, so create it once before recording: + +```bash +docker network create keploy-network +``` + ```bash keploy record -c "docker compose up" --container-name javaApp --build-delay 100 ``` @@ -320,6 +326,8 @@ or by querying through the browser `http://localhost:8080/api/employees/1` Now both these API calls were captured as **editable** testcases and written to `keploy/test` folder. The keploy directory would also have `mock.yml` file. +Once both calls are recorded, stop the recording with `Ctrl+C` in the terminal running `keploy record`. + Now, let's see the magic! πŸͺ„πŸ’« ### Running the testcases using Keploy