Skip to content

Commit

Permalink
Merge branch 'keploy:main' into dev-2
Browse files Browse the repository at this point in the history
  • Loading branch information
Swpn0neel authored Nov 1, 2024
2 parents 397e385 + a60e7a8 commit 0921c2d
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
id: unit-test-automation
title: What is Unit Test Automation?
seoTitle: "Understanding Unit Test Automation: A Comprehensive Guide"
seoDescription: "Discover what unit test automation is, its benefits, best practices, and how it streamlines software development for better quality."
sidebar_label: Unit Test Automation
description: Simplify Your Testing Workflow with Unit Test Automation. Streamline processes for efficient and effective software testing.
tags:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,34 +43,36 @@ git clone https://github.com/keploy/samples-typescript.git
cd samples-typescript/express-postgresql-prisma
```

### Install the dependencies
### Running App Locally on Linux/WSL

#### Install the dependencies

```bash
npm install
```

### Set up environment variables:
#### Set up environment variables:

```bash
cp .env.example .env
```

### Start PostgreSQL Container
#### Start PostgreSQL Container

```bash
docker run --name my-postgres -e POSTGRES_PASSWORD=mysecretpassword -p 5432:5432 -d postgres
```

> Note: PostgreSQL Password is `mysecretpassword`
### Update the `.env` file with your PostgreSQL connection string:
#### Update the `.env` file with your PostgreSQL connection string:

```bash
PORT=3000
DATABASE_URL="postgresql://postgres:mysecretpassword@localhost:5432/postgres"
```

### Migrate the database:
#### Migrate the database:

```bash
npm run generate
Expand Down Expand Up @@ -112,7 +114,7 @@ nt in 50ms
└─────────────────────────────────────────────────────────┘
```

### Start the application:
#### Start the application:

```bash
npm run dev
Expand All @@ -129,7 +131,7 @@ Server is listening at PORT 3000
Now we walkthrough how to leverage Keploy to automatically generate test cases for the application, and later test the application using Keploy.

### Generate Test Cases
#### Generate Test Cases

> Note: Build the application first using `npm run build`
Expand Down Expand Up @@ -173,6 +175,21 @@ The above command will start recording the API calls made to the application and
> 💡 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.
### Running App using Docker Compose 🐳
We will be using Docker compose to run the application as well as PostreSql 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).
--container-name: The container name in the docker-compose.yml for traffic interception.
```bash
keploy record -c "docker compose up" --container-name "express-postgresql-prisma-app" --build-delay 50
```
**🔥 Challenge time!** Generate some test cases. How? Just make some API calls. Postman, Hoppscotch or even curl - take your pick!
### Interact with Application
Make API Calls using [Hoppscotch](https://hoppscotch.io/), [Postman](https://www.postman.com/) or [cURL](https://curl.se/) command. Keploy with capture those calls to generate the test-suites containing testcases and data mocks.
Expand Down Expand Up @@ -317,10 +334,20 @@ curl -X 'DELETE' \
### Test the Application using Keploy
#### on Linux/WSL
```bash
keploy test -c "npm start"
```
#### On Docker Compose 🐳
```bash
keploy test -c "docker compose up" --container-name "nodeMongoApp" --build-delay 50 --delay 10
```
> The **--delay** flag? Oh, that's just giving your app a little breather (in seconds) before the test cases come knocking.
Keploy will replay the recorded interactions and validate the responses against the expected results.
```bash
Expand Down
4 changes: 2 additions & 2 deletions versioned_docs/version-2.0.0/running-keploy/docker-tls.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ keywords:

```dockerfile
# Download the ca.crt file
RUN curl -o ca.crt https://raw.githubusercontent.com/keploy/keploy/main/pkg/core/proxy/asset/ca.crt
RUN curl -o setup_ca.sh https://raw.githubusercontent.com/keploy/keploy/main/pkg/core/proxy/asset/setup_ca.sh
RUN curl -o ca.crt https://raw.githubusercontent.com/keploy/keploy/refs/heads/main/pkg/core/proxy/tls/asset/ca.crt
RUN curl -o setup_ca.sh https://raw.githubusercontent.com/keploy/keploy/refs/heads/main/pkg/core/proxy/tls/asset/setup_ca.sh
# Give execute permission to the setup_ca.sh script
RUN chmod +x setup_ca.sh

Expand Down

0 comments on commit 0921c2d

Please sign in to comment.