Skip to content

Commit 8210f91

Browse files
authored
Merge pull request #292 from ganesh-bruno/docs/revamp-cli-section
bruno cli section revamp
2 parents 7a00117 + cc8feb8 commit 8210f91

File tree

6 files changed

+232
-192
lines changed

6 files changed

+232
-192
lines changed

src/pages/bru-cli/_meta.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
export default {
2-
"overview": "Overview"
3-
}
2+
"overview": "Overview",
3+
"installation": "Installation",
4+
"commandOptions": "Command Options",
5+
"runCollection": "Run a Collection",
6+
"builtInReporters": "Generate Reports"
7+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Generating Reports
2+
3+
Bruno CLI provides built-in support for generating reports in three formats: **JSON**, **JUnit**, and **HTML**. These reports help with analyzing test results and integrating with various CI/CD tools.
4+
5+
You can generate any combination of these reports and even run them simultaneously.
6+
7+
### JSON Report
8+
9+
To generate a report in JSON format, use the `--reporter-json` option:
10+
11+
```bash copy
12+
bru run request.bru --reporter-json results.json
13+
```
14+
15+
This will output the test results in a results.json file, which can be useful for further processing or programmatic analysis.
16+
17+
### JUnit Report
18+
19+
To generate a report in JUnit format, use the --reporter-junit option:
20+
21+
```bash copy
22+
bru run request.bru --reporter-junit results.xml
23+
```
24+
25+
The results.xml file will be in a format compatible with JUnit, making it ideal for integration with CI/CD pipelines that rely on JUnit reporting.
26+
27+
28+
### HTML Report
29+
30+
To generate a human-readable HTML report, use the --reporter-html option:
31+
32+
```bash copy
33+
bru run request.bru --reporter-html results.html
34+
```
35+
36+
This will create an results.html file that provides a visual representation of the test outcomes, ideal for quick reviews.
37+
38+
### Running Multiple Reporters Simultaneously
39+
40+
You can generate multiple reports at once by specifying more than one reporter option. For example, to generate JSON, JUnit, and HTML reports simultaneously, run:
41+
42+
```bash copy
43+
bru run request.bru --reporter-json results.json --reporter-junit results.xml --reporter-html results.html
44+
```
45+
46+
This command will create three files: results.json, results.xml, and results.html, allowing you to analyze the results in different formats as needed.
47+

src/pages/bru-cli/commandOptions.mdx

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
2+
# Command Options
3+
4+
Bruno CLI provides a variety of command options to help you customize your API testing and execution process. These options allow you to specify environments, configure reports, handle security, and much more. Below is a comprehensive list of available options:
5+
6+
## Bruno version
7+
To check the current version of your Bruno CLI installation, use the following command:
8+
9+
```bash copy
10+
bru --version
11+
```
12+
This will display the version number of the Bruno CLI you have installed. It's a helpful command for ensuring you're working with the latest version or for troubleshooting version-specific issues.
13+
14+
15+
## Options
16+
17+
| Option | Details |
18+
| ---------------------------- | ----------------------------------------------------------------------------- |
19+
| -h, --help | Show help |
20+
| --version | Show version number |
21+
| -r | Indicates a recursive run (default: false) |
22+
| --cacert [string] | CA certificate to verify peer against |
23+
| --env [string] | Specify environment to run with |
24+
| --env-var [string] | Overwrite a single environment variable, multiple usages possible |
25+
| -o, --output [string] | Path to write file results to |
26+
| -f, --format [string] | Format of the file results; available formats are "json" (default) or "junit" |
27+
| --reporter-json [string] | Path to generate a JSON report |
28+
| --reporter-junit [string] | Path to generate a JUnit report |
29+
| --reporter-html [string] | Path to generate an HTML report |
30+
| --insecure | Allow insecure server connections |
31+
| --tests-only | Only run requests that have tests |
32+
| --bail | Stop execution after a failure of a request, test, or assertion |
33+
| --csv-file-path | CSV file to run the collection with |
34+
| --reporter--skip-all-headers | Skip all headers in the report |
35+
| --reporter-skip-headers | Skip specific headers in the report |
36+
| --client-cert-config | Client certificate configuration by passing a JSON file |
37+
| --delay [number] | Add delay to each request |
38+
39+
## Demo
40+
![bru cli](/screenshots/cli-demo.webp)
41+
42+
## Support
43+
If you encounter any issues or have any feedback or suggestions, please raise them on our [GitHub repository](https://github.com/usebruno/bruno)

src/pages/bru-cli/installation.mdx

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { Callout } from 'nextra/components'
2+
3+
4+
# Installation
5+
6+
<Callout emoji="">
7+
Make sure you have Node.js installed on your local system. It is recommended to use the latest LTS version (Node 18 or higher).
8+
</Callout>
9+
10+
To install the Bruno CLI, use the node package manager of your choice, such as NPM:
11+
```bash copy
12+
npm install -g @usebruno/cli
13+
```
14+
15+
## Getting Started
16+
17+
Navigate to the directory where your API collection resides, and run the following command:
18+
19+
```bash copy
20+
bru run
21+
```
22+
23+
This will run all the requests in your collection. If you want to run a single request, specify its filename:
24+
25+
```bash copy
26+
bru run request.bru
27+
```
28+
29+
## Running Requests in a Folder
30+
To run all the requests within a folder, use:
31+
32+
```bash copy
33+
bru run folder
34+
```
35+
36+
## Using Environments
37+
If you need to use a specific environment, you can pass it with the --env option:
38+
39+
```bash copy
40+
bru run folder --env Local
41+
```
42+
43+
## Passing Environment Variables
44+
45+
> Variables marked as secrets in Bruno app are not accessible via the CLI. Pass them directly as command-line arguments.
46+
47+
```bash copy
48+
bru run folder --env Local --env-var JWT_TOKEN=1234
49+
```
50+

src/pages/bru-cli/overview.mdx

Lines changed: 5 additions & 190 deletions
Original file line numberDiff line numberDiff line change
@@ -4,198 +4,13 @@ With Bruno CLI, you can run your API collections with ease using simple command
44

55
This makes it easier to test your APIs in different environments, automate your testing process, and integrate your API tests with your continuous integration and deployment workflows.
66

7-
## Installation
8-
To install the Bruno CLI, use the node package manager of your choice, such as NPM:
9-
```bash copy
10-
npm install -g @usebruno/cli
11-
```
127

13-
## Getting Started
8+
## Key Features of Bruno CLI:
149

15-
Navigate to the directory where your API collection resides, and run the following command:
10+
**1. Execute API Requests & Collections**: Run individual API requests or entire collections directly from the command line.
1611

17-
```bash copy
18-
bru run
19-
```
12+
**2. Generate Test Reports** : Easily create reports in multiple formats, including JSON, JUnit, and HTML, to analyze and share test results.
2013

21-
This will run all the requests in your collection. If you want to run a single request, specify its filename:
14+
**3. CI/CD Integration**: Effortlessly integrate with CI/CD pipelines for automated testing and validation.
2215

23-
```bash copy
24-
bru run request.bru
25-
```
26-
27-
## Running Requests in a Folder
28-
To run all the requests within a folder, use:
29-
30-
```bash copy
31-
bru run folder
32-
```
33-
34-
## Using Environments
35-
If you need to use a specific environment, you can pass it with the --env option:
36-
37-
```bash copy
38-
bru run folder --env Local
39-
```
40-
41-
## Passing Environment Variables
42-
43-
> Variables marked as secrets in Bruno app are not accessible via the CLI. Pass them directly as command-line arguments.
44-
45-
```bash copy
46-
bru run folder --env Local --env-var JWT_TOKEN=1234
47-
```
48-
49-
## Running a Collection with a CSV File
50-
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:
51-
52-
```bash copy
53-
bru run folder --csv-file-path /path/to/csv/file.csv
54-
```
55-
56-
## Running a Collection with a JSON File
57-
To run a collection using data from a JSON file, provide the file path using the `--json-file-path` option:
58-
59-
```bash copy
60-
bru run folder --json-file-path /path/to/json/file.json
61-
```
62-
> This feature requires Bruno CLI version 1.35.0 or higher.
63-
64-
65-
## Outputting Results
66-
To save the results of your API tests to a file, use the --output option:
67-
68-
```bash copy
69-
bru run folder --output results.json
70-
```
71-
72-
## Skipping Specific Headers in the Report
73-
74-
If you want to exclude certain headers from the report, use the `--reporter-skip-headers` option. You can list multiple headers to skip, separated by spaces.
75-
76-
```bash
77-
bru run --reporter-html results.html --reporter-skip-headers "Authorization" "Content-Type" "Date"
78-
```
79-
80-
## Skip All Headers in the Report
81-
82-
To exclude all headers from the report, use the `--reporter-skip-all-headers` option. This will remove all headers from the output report, ensuring a cleaner result.
83-
84-
```bash copy
85-
bru run --reporter-html results.html --reporter-skip-all-headers
86-
```
87-
88-
## Using Client Certificates for API Requests
89-
90-
If your API requests require client certificates for authentication, you can specify using the `--client-cert-config` option. The configuration should be provided in a JSON file. Here's an example of how to use this option:
91-
92-
```bash copy
93-
bru run folder --client-cert-config /path/to/client-cert-config.json
94-
```
95-
96-
The client-cert-config.json file should contain the following fields:
97-
98-
```json
99-
{
100-
"enabled": true,
101-
"certs": [
102-
{
103-
"domain": "usebruno.com",
104-
"type": "cert",
105-
"certFilePath": "certs/server_1.crt",
106-
"keyFilePath": "private/server_1.key",
107-
"passphrase": "Iu$eBrun0_#Secure!"
108-
},
109-
{
110-
"domain": "the-example.com",
111-
"type": "pfx",
112-
"pfxFilePath": "pfx/server_3.pfx",
113-
"passphrase": "L!ghT_Y@g@mi_2024!"
114-
}
115-
]
116-
}
117-
```
118-
## Adding Delay
119-
If you need to add a delay between requests during the execution of your API collection, you can use the `--delay` option.
120-
121-
Example:
122-
```bash copy
123-
bru run . --delay 1000
124-
```
125-
## Generating Reports
126-
127-
Bruno CLI provides built-in support for generating reports in three formats: **JSON**, **JUnit**, and **HTML**. These reports help with analyzing test results and integrating with various CI/CD tools.
128-
129-
You can generate any combination of these reports and even run them simultaneously.
130-
131-
### JSON Report
132-
133-
To generate a report in JSON format, use the `--reporter-json` option:
134-
135-
```bash copy
136-
bru run request.bru --reporter-json results.json
137-
```
138-
139-
This will output the test results in a results.json file, which can be useful for further processing or programmatic analysis.
140-
141-
### JUnit Report
142-
143-
To generate a report in JUnit format, use the --reporter-junit option:
144-
145-
```bash copy
146-
bru run request.bru --reporter-junit results.xml
147-
```
148-
149-
The results.xml file will be in a format compatible with JUnit, making it ideal for integration with CI/CD pipelines that rely on JUnit reporting.
150-
151-
152-
### HTML Report
153-
154-
To generate a human-readable HTML report, use the --reporter-html option:
155-
156-
```bash copy
157-
bru run request.bru --reporter-html results.html
158-
```
159-
160-
This will create an results.html file that provides a visual representation of the test outcomes, ideal for quick reviews.
161-
162-
### Running Multiple Reporters Simultaneously
163-
164-
You can generate multiple reports at once by specifying more than one reporter option. For example, to generate JSON, JUnit, and HTML reports simultaneously, run:
165-
166-
```bash copy
167-
bru run request.bru --reporter-json results.json --reporter-junit results.xml --reporter-html results.html
168-
```
169-
170-
This command will create three files: results.json, results.xml, and results.html, allowing you to analyze the results in different formats as needed.
171-
172-
173-
## Options
174-
175-
| Option | Details |
176-
| ---------------------------- | ----------------------------------------------------------------------------- |
177-
| -h, --help | Show help |
178-
| --version | Show version number |
179-
| -r | Indicates a recursive run (default: false) |
180-
| --cacert [string] | CA certificate to verify peer against |
181-
| --env [string] | Specify environment to run with |
182-
| --env-var [string] | Overwrite a single environment variable, multiple usages possible |
183-
| -o, --output [string] | Path to write file results to |
184-
| -f, --format [string] | Format of the file results; available formats are "json" (default) or "junit" |
185-
| --reporter-json [string] | Path to generate a JSON report |
186-
| --reporter-junit [string] | Path to generate a JUnit report |
187-
| --reporter-html [string] | Path to generate an HTML report |
188-
| --insecure | Allow insecure server connections |
189-
| --tests-only | Only run requests that have tests |
190-
| --bail | Stop execution after a failure of a request, test, or assertion |
191-
| --csv-file-path | CSV file to run the collection with |
192-
| --reporter--skip-all-headers | Skip all headers in the report |
193-
| --reporter-skip-headers | Skip specific headers in the report |
194-
| --client-cert-config | Client certificate configuration by passing a JSON file |
195-
| --delay [number] | Add delay to each request |
196-
197-
## Demo
198-
![bru cli](/screenshots/cli-demo.webp)
199-
200-
## Support
201-
If you encounter any issues or have any feedback or suggestions, please raise them on our [GitHub repository](https://github.com/usebruno/bruno)
16+
For more details, visit the official [NPM Page for Bruno CLI](https://www.npmjs.com/package/@usebruno/cli)

0 commit comments

Comments
 (0)