Bruno's CLIRun a Collection

Running a Collection

Bruno CLI allows you to run your API collections with ease, either by directly executing requests or using external data sources.

This guide explains how to run entire collections, specific folders, and how to use data sources like CSV and JSON files to drive your API tests.

Basic Collection Execution

To run an entire collection, navigate to your collection directory and use the run command:

bru run

Running a Folder within a Collection

You can run all the requests within a specific folder by specifying the folder name:

bru run <folder-name>

For example, to run all requests in the users folder:

bru run users

Running a Collection with a CSV File

This feature requires Bruno CLI version 1.35.0 or higher.

If you need to run a collection using data from a CSV file, specify the path to the file with the --csv-file-path option:

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

This will execute the collection once for each row in the CSV file, with each row’s data available as variables in your requests.

Running a Collection with a JSON File

To run a collection using data from a JSON file, provide the file path using the --json-file-path option:

bru run --json-file-path /path/to/json/file.json

Running a Collection Multiple Times

You can run a collection multiple times in a single command using the --iteration-count flag:

bru run --iteration-count=2

This will execute the collection twice. This is useful for load testing or when you need to repeat the same set of requests multiple times.

Running a Collection with Environment Files

You can run a collection using environment variables from a .bru file. This allows you to attach environments via the CLI from anywhere in the filesystem.

Using Environment Files

To run a collection with an environment file, use the --env-file option:

bru run --env-file /path/to/environment.bru

You can specify either a relative or absolute path to the environment file:

# Using relative path
bru run --env-file ./environments/local.bru
 
# Using absolute path
bru run --env-file /Users/username/projects/api-testing/environments/prod.bru

The environment file should be in Bruno’s .bru format. Make sure the file contains valid environment variables and their values.