|
3 | 3 | This is a petclinic app where you can record testcases and mocks by interacting with the UI, and then test them using Keploy.
|
4 | 4 | This project has two parts - the frontend and backend, since Keploy is a backend testing platform, we need to start the backend part of the project
|
5 | 5 | using Keploy and run the frontend as it is.
|
| 6 | +You can start the backend using Keploy in 2 ways: |
| 7 | +- Using Keploy's binary. |
| 8 | +- Using Keploy's docker image. |
6 | 9 |
|
7 |
| -Prerequisites: |
| 10 | +Prerequisites For Binary: |
8 | 11 | 1. Node 20.11.0 LTS
|
9 |
| -2. Docker Desktop 4.25.2 and above |
| 12 | +2. OpenJDK 17.0.9 |
10 | 13 | 3. MVN version 3.6.3
|
11 | 14 |
|
| 15 | +Prerequisites For Docker: |
| 16 | +1. Docker Desktop 4.25.2 and above |
| 17 | + |
12 | 18 | ## Setup the frontend
|
13 | 19 |
|
14 | 20 | ```
|
|
27 | 33 | npm run start
|
28 | 34 | ```
|
29 | 35 |
|
| 36 | +# Instructions For Starting Using Binary |
| 37 | + |
30 | 38 | ## Spin up the database
|
31 | 39 |
|
32 | 40 | ```
|
|
64 | 72 | spring.datasource.url=jdbc:postgresql://localhost:5432/petclinic
|
65 | 73 | ```
|
66 | 74 |
|
67 |
| -## Run the backend with Keploy(binary) |
| 75 | +## Recording the testcases with Keploy |
68 | 76 |
|
69 | 77 | ```
|
70 | 78 | keploy record -c "java -jar target/<name-of-your-jar>"
|
71 | 79 | ```
|
| 80 | +Now you can start interacting with the UI and Keploy will automatically create the testcases and mocks for it in a folder named 'keploy'. |
72 | 81 |
|
73 |
| -Now when you interact with the UI, the tests should start getting created in a folder called 'keploy' in the directory where you started the backend. When you are done recording the testcases and mocks, you can run them using keploy. |
74 |
| - |
75 |
| -## Starting the backend with Keploy(docker) |
76 |
| -Starting the backend with keploy requires just a small change in the script used to run Keploy. The command will look something like this: |
77 |
| - |
78 |
| -### For docker on Mac |
79 |
| - |
80 |
| -``` |
81 |
| -alias keploy='sudo docker run --pull always --name keploy-v2 -e BINARY_TO_DOCKER=true -p 16789:16789 --privileged --pid=host -it -v " + os.Getenv("PWD") + ":/files -v /sys/fs/cgroup:/sys/fs/cgroup -v debugfs:/sys/kernel/debug:rw -v /sys/fs/bpf:/sys/fs/bpf -v /var/run/docker.sock:/var/run/docker.sock -v " + os.Getenv("HOME") + "/.keploy-config:/root/.keploy-config -v " + os.Getenv("HOME") + "/.keploy:/root/.keploy --rm ghcr.io/keploy/keploy' |
82 |
| -``` |
83 |
| - |
84 |
| -### For docker on Linux |
85 |
| - |
86 |
| -``` |
87 |
| -alias keploy='sudo docker run --pull always --name keploy-v2 -e BINARY_TO_DOCKER=true -p 16789:16789 --privileged --pid=host -it -v " + os.Getenv("PWD") + ":/files -v /sys/fs/cgroup:/sys/fs/cgroup -v /sys/kernel/debug:/sys/kernel/debug -v /sys/fs/bpf:/sys/fs/bpf -v /var/run/docker.sock:/var/run/docker.sock -v " + os.Getenv("HOME") + "/.keploy-config:/root/.keploy-config -v " + os.Getenv("HOME") + "/.keploy:/root/.keploy --rm ghcr.io/keploy/keploy' |
88 |
| -
|
89 |
| -``` |
| 82 | +## Running the testcases using Keploy |
90 | 83 |
|
91 | 84 | ```
|
92 |
| -keploy record -c "docker compose up" --containerName javaApp --buildDelay 50s |
| 85 | +keploy test -c "java -jar target/<name-of-your-jar>" --delay 20 |
93 | 86 | ```
|
94 | 87 |
|
95 |
| -## Running the testcases using Keploy(binary) |
| 88 | +# Instructions For Starting Using Docker |
| 89 | +Here we just need to change the command used to start the application and it should work correctly. |
96 | 90 |
|
97 | 91 | ```
|
98 |
| -keploy test -c "java -jar target/<name-of-your-jar>" --delay 10 |
| 92 | +keploy record -c "docker compose up" --containerName javaApp --buildDelay 100s |
99 | 93 | ```
|
100 | 94 |
|
101 |
| -## Running the testcases using Keploy(docker) |
| 95 | +## Running the testcases using Keploy |
102 | 96 |
|
103 | 97 | ```
|
104 |
| -keploy test -c "docker compose up" --containerName javaApp --buildDelay 50s --delay 10 |
| 98 | +keploy test -c "docker compose up" --containerName javaApp --buildDelay 50s --delay 20 |
105 | 99 | ```
|
106 | 100 | Here `delay` is the time it takes for your application to get started, after which Keploy will start running the testcases. If your application takes longer than 10s to get started, you can change the `delay` accordingly.
|
107 | 101 | `buildDelay` is the time that it takes for the image to get built. This is useful when you are building the docker image from your docker compose file itself.
|
|
0 commit comments