| draft | false |
|---|---|
| title | Your 1st Bruno Collection Mock |
| date | 2026-04-09 |
| publishdate | 2026-04-09 |
| lastmod | 2026-04-09 |
| weight | 8 |
Bruno is a fast and git-friendly API client that aims to revolutionize the Postman experience. Unlike traditional API clients that store collections in proprietary cloud formats, Bruno keeps everything simple and version-controlled using plain text files.
This tutorial demonstrates how to use Bruno collections with Microcks to mock and test your APIs. Bruno collections can be used as a source of truth for your API contracts, enabling Microcks to generate realistic mocks directly from your existing Bruno setup.
Combining Bruno with Microcks offers several advantages:
- Git-friendly: Bruno stores collections in a flat folder structure with
.brufiles, making it easy to version control and collaborate using Git - Offline-first: No cloud dependencies - your collections live locally on your filesystem
- Consistency: Use the same collections for manual testing (Bruno) and automated mocking/testing (Microcks)
- Speed: Bruno is lightweight and fast, with no sync delays
For this tutorial, you'll need a running Microcks instance. The simplest way to get started is using Docker:
docker run -p 8585:8080 -p 9393:8081 --name microcks \
-e ASYNC_MINION_URL=http://localhost:8081 \
quay.io/microcks/microcks:latestWait for Microcks to start, then navigate to http://localhost:8585.
If you haven't already, download and install Bruno from https://www.usebruno.com/downloads. Bruno is available for macOS, Linux, and Windows.
Let's create a simple collection for a "Books API". Open Bruno and create a new collection named "Books API":
Create a new request within your collection:
- Method: GET
- URL:
{{baseUrl}}/books - Name: Get All Books
Add a response example directly in Bruno. In the response section, add:
[
{
"id": "1",
"title": "The Pragmatic Programmer",
"author": "David Thomas",
"year": 1999
},
{
"id": "2",
"title": "Clean Code",
"author": "Robert C. Martin",
"year": 2008
}
]Add another request for creating books:
- Method: POST
- URL:
{{baseUrl}}/books - Name: Create Book`
In the Body tab, select JSON and add:
{
"title": "Clean Architecture",
"author": "Robert C. Martin",
"year": 2017
}Add a response example with status 201 Created:
{
"id": "3",
"title": "Clean Architecture",
"author": "Robert C. Martin",
"year": 2017
}Bruno stores collections in a folder structure like this:
books-api/
├── collections/
│ └── books-api/
│ ├── get-books.bru
│ ├── post-books.bru
│ └── bruno.json
└── environments/
└── local.bru
To export your collection for Microcks:
- Right-click on your collection in Bruno
- Select Export or Save as Collection File
- Choose a location and save as a
.zipor individual.brufiles
Alternatively, you can directly use the folder structure with Git and import it into Microcks.
Microcks supports importing Bruno collections through the web UI or CLI:
- Go to your Microcks instance at
http://localhost:8585 - Navigate to Importers in the left sidebar
- Click Upload and select your Bruno collection files
- Microcks will parse the
.brufiles and create mocks
You can also use the Microcks CLI for automation:
microcks import ./path/to/bruno-collection/Once imported, Microcks will:
- Parse all requests and responses from your
.brufiles - Create mock endpoints for each operation
- Generate example responses based on your Bruno examples
For our Books API, Microcks will create:
GET /books→ Returns the list of booksPOST /books→ Creates a new book and returns the created resource
Try accessing the mocks with curl:
curl http://localhost:8585/rest/Books+API/1.0.0/books -s | jqYou should see the response examples you defined in Bruno.
Bruno collections support variables and scripting. While Bruno scripts are not directly executed by Microcks, you can enhance your mocks by:
- Using dynamic expressions: Add Microcks templating expressions in your response examples
- Secondary artifacts: Import a secondary artifact with custom logic
Example with dynamic content:
In your Bruno .bru file response, you can use Microcks expressions:
{
"id": "{{ uuid() }}",
"title": "{{ request.body/title }}",
"createdAt": "{{ now() }}"
}When using Bruno with Microcks:
- Keep examples realistic: Microcks will use your Bruno examples as-is, so make them representative of real data
- Use consistent naming: Follow a consistent naming convention for your requests
- Leverage environments: Use Bruno environments to manage different base URLs
- Version your collections: Store your
.brufiles in Git for proper versioning - Document as you go: Add descriptions to requests and collections for better documentation
In this tutorial, we've seen how Bruno collections can be used with Microcks to create a seamless API development workflow. By keeping your collections in a git-friendly format with Bruno, you get the best of both worlds:
- Fast, offline-first API development with Bruno
- Automated mocking and testing with Microcks
💡 Bruno support in Microcks is an evolving feature. If you encounter any issues or have suggestions, please open an issue on GitHub.
Happy mocking! 📚