A sample Employee-Manager app to test Keploy integration capabilities using SpringBoot and PostgreSQL.
Note :- Issue Creation is disabled on this Repository, please visit here to submit Issue.
Based on your OS and preference(Docker/Native), you setup Keploy using One-click installation method:-
curl -O https://raw.githubusercontent.com/keploy/keploy/main/keploy.sh && source keploy.shClone the repository and install the dependencies
git clone https://github.com/keploy/samples-java && cd employee-manager
mvn clean install -Dmaven.test.skip=true Once we have our jar file ready,this command will start the recording of API calls using ebpf:-
sudo -E env PATH=$PATH keploy record -c "java -jar target/springbootapp-0.0.1-SNAPSHOT.jar"Now let's run a few tests to capture some more scenarios:
To generate testcases we just need to make some API calls. You can use Postman, Hoppscotch, or simply curl
- Make an employee entry
curl --location --request POST 'http://localhost:8080/api/employees' \
--header 'Content-Type: application/json' \
--data-raw '{
"firstName": "Myke",
"lastName": "Tyson",
"email": "mt@gmail.com",
"timestamp":1
}'this will return the response or an entry. The timestamp would automatically be ignored during testing because it'll always be different.
{
"id": 1,
"firstName": "Myke",
"lastName": "Tyson",
"email": "mt@gmail.com",
"timestamp": 1661493301
}
- Fetch recorded info about employees
curl --location --request GET 'http://localhost:8080/api/employees/1'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.
Now, let's see the magic! 🪄💫
Now, let's run the keploy in test mode: -
sudo -E env PATH=$PATH keploy test -c "java -jar target/springbootapp-0.0.1-SNAPSHOT.jar" --delay 10This will run the testcases and generate the report in keploy/testReports folder.
