Bruno gives you a built-in Collection Runner with unlimited runs (unlike other API clients), but as you get your tests standardized often there's a need for more flexibility and automation.
The Bruno CLI allows you to skip the GUI and run your Bruno collections straight from the shell. At the time of this writing, our npm package is getting roughly 120,000 downloads a week - so you'll be in good company with other devs that have baked Bruno CLI into their workflows.
This posts walks through how to get started with the CLI as well as some more advanced options for configuration and running.
npm install -g @usebruno/cli
bru run
Below I've run a collection that has contract tests using Zod, which can be found in a previous blog post. We can see the total number of requests, tests, and assertions that were run, as well as any failure details.
Easily switch between environments (e.g. test, staging, prod 😈) with:
bru run --env Staging
Variables marked as secrets in the Bruno app aren’t exposed via CLI. Pass them explicitly:
bru run --env-var API_TOKEN=xxx
To data-drive your runs, point at a CSV or JSON file:
bru run users --csv-file-path data/users.csv
bru run orders --json-file-path data/orders.json
Generate HTML, JUnit, and/or JSON reports. Great for integration into an existing test suite or reporting engine.
bru run request.bru --reporter-json results.json
--reporter-junit results.xml
--reporter-html results.html
name: API Tests
on: [push]
jobs:
api-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: npm install -g @usebruno/cli
- run: |
bru run \
--env CI \
--reporter-json ci-report.json \
--bail
--bail
stops on first failure.--reporter-html report.html
for visual overviews.🛠️ Peek the code or open issues on GitHub. Happy testing!