Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add api test cases documentation #99

Merged
merged 2 commits into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ Imagine having a central hub where you can create and send notifications seamles
- [Production Setup](docs/production-setup.md)
- [Usage Guide](docs/usage-guide.md)
- [Add New Provider](docs/add-new-provider.md)
- [Block Diagram](/docs/block-diagram.md)
- [Block Diagram](docs/block-diagram.md)
- [API Test Cases](docs/api-test-cases.md)

## Contributing

Expand Down
80 changes: 80 additions & 0 deletions apps/api/docs/api-test-cases.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# API Test Cases Documentation

This document provides instructions on how to run the API test cases using Postman and Newman.

## Prerequisites

Before running the test cases, make sure you have the following prerequisites installed:

- [Postman](https://www.postman.com/downloads/)
- [Node.js](https://nodejs.org/) (v20.x or higher)

## Getting Started

1. Clone the repository (if not already done):

```bash
git clone [email protected]:OsmosysSoftware/osmo-notify.git
```

2. Install Newman globally (for using Newman):

```bash
npm install -g newman

# Optional, for generating HTML reports
npm install -g newman-reporter-html
```

3. Import the Postman collection:

1. Open Postman.
2. Click on the `Import` button.
3. Select the `apps/api/osmo-notify.postman_collection.json` file.

## Running Test Cases

### Using Postman

1. Open Postman.
2. Select the imported collection and click on the `Run` button near the top right.

Alternatively, click the three dots beside the collection name and click `Run collection`

3. Select the environment on top right.
4. Click `Run osmo-notify` to execute the test cases.

### Using Newman

1. Export the environment file from Postman.
2. Open a terminal and run one of the following commands:

1. For console output

```bash
newman run osmo-notify.postman_collection.json -e osmo-notify.postman_environment.json
```

2. For HTML report

```bash
newman run osmo-notify.postman_collection.json -e osmo-notify.postman_environment.json -r html
```

Specify the path to the collection and environment file as required.

## Viewing Results

Both Postman and Newman provide detailed reports after running the test cases. You can view:

- **Run results (for Postman):** Check the results on the Run results page in Postman after testing is completed.

![Postman run results](assets/postman-api-run-results.png)

- **Console Output (for Newman):** Check the terminal/console for test execution details.

![Newman CLI run results](assets/newman-cli-run-results.png)

- **HTML Report (for Newman):** After running Newman with the `-r html` flag, an HTML report is generated. Open the `newman/` directory and find the HTML file.

![Newman HTML report](assets/newman-html-report.png)
Binary file added apps/api/docs/assets/newman-cli-run-results.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/api/docs/assets/newman-html-report.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/api/docs/assets/postman-api-run-results.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading