parent directory.. | ||||
View all files | ||||
A sample user data CRUD app to test Keploy integration capabilities using FastAPI and PostgreSQL.
Make the following requests to the respective endpoints -
Keploy can be installed on Linux directly and on Windows with the help of WSL. Based on your system architecture, install the keploy latest binary release
If we have setup our sample-app with docker, we need to update the container name to postgres on line 6, in application/database.py, from postgresql://postgres:postgres@localhost:5432/studentdb to postgresql://postgres:postgres@postgres:5432/studentdb.
Also, we need to update the container name to postgres on line 11, of application/main.py, from postgresql://postgres:postgres@localhost:5432/studentdb to postgresql://postgres:postgres@postgres:5432/studentdb.
This command will start the recording of API calls :
Make API Calls using Hoppscotch, Postman or cURL command. Keploy with capture those calls to generate the test-suites containing testcases and data mocks.
This will return all the data saved in the database.
Now all 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.
Now let's run the application in test mode.
We will get output something like below -
By making just 2 api call, we have generated a complete test suite for our application and acheived 72% coverage.
So, no need to setup fake database/apis like Postgres or write mocks for them. Keploy automatically mocks them and, The application thinks it's talking to Postgres 😄