Exploring Bruno API Testing: How to Run a Collection
Running your API tests effectively can significantly improve your development workflow. One tool that excels in this area is Bruno. In this article, we'll explore how to run a collection in Bruno, and at the end, I'll introduce you to EchoAPI as a lightweight alternative.
Running your API tests effectively can significantly improve your development workflow. One tool that excels in this area is Bruno. In this article, we'll explore how to run a collection in Bruno, and at the end, I'll introduce you to EchoAPI as a lightweight alternative.
What is Bruno?
Bruno is an intuitive API testing tool designed to streamline your testing process. With its built-in Collection Runner, you can run API collections quickly and efficiently. Let’s dive into how you can use this feature.
Running Your Bruno Collection
Using the Collection Runner
To start, the Collection Runner in Bruno allows you to run your API collections with just a click. You can either:
Or, you can click the Collection Runner icon at the top of the application.
Click the ... button next to your collection in the sidebar and select Run.
Once you’ve launched the Collection Runner, you can add parameters or set delays between requests, enhancing the flexibility of your tests.
Data-Driven Testing
For users with the Golden and Ultimate Edition, Bruno offers data-driven testing using a .CSV file. This feature enables you to run multiple tests with different input data seamlessly.
Automating Runs in CI/CD
Bruno also provides a command-line interface (CLI) to automate your API tests, making it easier to integrate them into your CI/CD workflows. Here’s how to get started:
Installation
To install the Bruno CLI, simply run:
npm install -g @usebruno/cli
Running Your Collections
Navigate to your API collection directory and run:
bru run
You can also specify single requests or entire folders, use environment variables, or even run collections using data from a CSV file.
Generating Reports
After running your tests, you’ll likely want to analyze the results. Bruno CLI supports generating reports in JSON, JUnit, and HTML formats, allowing for easy integration with various CI/CD tools.
For example, to generate a JSON report, you can use:
bru run request.bru --reporter-json results.json
You can even generate multiple report formats simultaneously, which is useful for comprehensive reviews.
Why Consider EchoAPI?
While Bruno is a fantastic tool, you might also want to check out EchoAPI for VS Code. This ultra-lightweight tool is great for API development, coming with features such as:
- No login required
- Scratch Pad support
- 100% compatibility with Postman script syntax
EchoAPI is a superb alternative if you're looking for simplicity and ease of use. It has plugins for IntelliJ IDEA, VS Code, and a Chrome request capture extension.
Conclusion
Bruno provides robust and efficient tools for running your API tests, but don't overlook alternatives like EchoAPI for your development needs. Both tools have their strengths, and integrating either into your workflow can greatly enhance productivity.