Exploring Bruno API Testing: How to Use Bruno CLI

When it comes to API testing, simplicity and efficiency are crucial. Enter Bruno CLI—a command-line interface that streamlines your API testing process. With Bruno, you can effortlessly run your API collections, automate tests, and integrate them into your CI/CD workflows.

When it comes to API testing, simplicity and efficiency are crucial. Enter Bruno CLI—a command-line interface that streamlines your API testing process. With Bruno, you can effortlessly run your API collections, automate tests, and integrate them into your CI/CD workflows. Let’s dive into how you can get started with Bruno CLI and make your API testing a breeze!

Bruno CLI Demo

Installation

To kick things off, you’ll need to install the Bruno CLI. If you’re using Node.js, simply run:

npm install -g @usebruno/cli

Getting Started

Once installed, head to the directory that contains your API collection. Running the commands is straightforward! To execute all requests in your collection, use:

bru run

Want to run just one request? Specify the filename like this:

bru run request.bru

Running Requests in a Folder

If you have multiple requests in a folder, you can run them all at once:

bru run folder

Using Environments

Sometimes you need to test in specific environments. You can easily specify this with the --env option:

bru run folder --env Local

Passing Environment Variables

Need to pass some environment variables? Use the --env-var option:

bru run folder --env Local --env-var JWT_TOKEN=1234

Running a Collection with a CSV File

If your tests require data input, you can use a CSV file:

bru run folder --csv-file-path /path/to/csv/file.csv

Outputting Results

To keep track of your results, save them to a file using the --output option:

bru run folder --output results.json

Generating Reports

Bruno CLI makes it easy to generate test reports in JSON, JUnit, and HTML formats. This is vital for analyzing your results!

JSON Report

Generate a JSON report with:

bru run request.bru --reporter-json results.json

JUnit Report

For a JUnit report, run:

bru run request.bru --reporter-junit results.xml

HTML Report

A human-readable HTML report is available as well:

bru run request.bru --reporter-html results.html

Running Multiple Reporters Simultaneously

Want all three reports at once? Just run:

bru run request.bru --reporter-json results.json --reporter-junit results.xml --reporter-html results.html

Options Overview

Bruno CLI is packed with helpful options. Here are some key ones:

  • -h, --help: Show help
  • --version: Show version number
  • --env [string]: Specify the environment
  • --output [string]: Path to write results
  • --reporter-json [string]: Generate a JSON report

Conclusion: A Better Alternative - EchoAPI

While Bruno CLI is an excellent tool for API testing, consider checking out EchoAPI as well. It's an ultra-lightweight collaboration tool that excels in API development and offers features like API design, debugging, automated testing, and load testing. Here’s why EchoAPI stands out:

An Alternative to Consider: EchoAPI.png
  1. No login required
  2. Supports Scratch Pad
  3. Ultra lightweight
  4. 100% compatible with Postman script syntax

If you’re looking for a versatile and user-friendly alternative, EchoAPI might be exactly what you need!