@@ -46,9 +46,9 @@ bashunit test tests/ --parallel --simple
4646| Option | Description |
4747| --------| -------------|
4848| ` -a, --assert <fn> <args> ` | Run a standalone assert function |
49- | ` -e, --env, --boot <file> ` | Load custom env/bootstrap file |
49+ | ` -e, --env, --boot <file> ` | Load custom env/bootstrap file (supports args) |
5050| ` -f, --filter <name> ` | Only run tests matching name |
51- | ` -l, - -log-junit <file> ` | Write JUnit XML report |
51+ | ` --log-junit <file> ` | Write JUnit XML report |
5252| ` -p, --parallel ` | Run tests in parallel (default) |
5353| ` --no-parallel ` | Run tests sequentially |
5454| ` -r, --report-html <file> ` | Write HTML report |
@@ -62,6 +62,8 @@ bashunit test tests/ --parallel --simple
6262| ` --debug [file] ` | Enable shell debug mode |
6363| ` --no-output ` | Suppress all output |
6464| ` --strict ` | Enable strict shell mode |
65+ | ` --preserve-env ` | Skip ` .env ` loading, use shell environment only |
66+ | ` -l, --login ` | Run tests in login shell context |
6567
6668### Standalone Assert
6769
@@ -92,6 +94,42 @@ bashunit test tests/ --filter "user_login"
9294```
9395:::
9496
97+ ### Environment / Bootstrap
98+
99+ > ` bashunit test -e|--env|--boot <file> `
100+ > ` bashunit test --env "file arg1 arg2" `
101+
102+ Load a custom environment or bootstrap file before running tests.
103+
104+ ::: code-group
105+ ``` bash [Basic usage]
106+ bashunit test --env tests/bootstrap.sh tests/
107+ ```
108+ ``` bash [With arguments]
109+ # Pass arguments to the bootstrap file
110+ bashunit test --env " tests/bootstrap.sh staging verbose" tests/
111+ ```
112+ :::
113+
114+ Arguments are available as positional parameters (` $1 ` , ` $2 ` , etc.) in your bootstrap script:
115+
116+ ``` bash
117+ #! /usr/bin/env bash
118+ # tests/bootstrap.sh
119+ ENVIRONMENT=" ${1:- production} "
120+ VERBOSE=" ${2:- false} "
121+
122+ export API_URL=" https://${ENVIRONMENT} .api.example.com"
123+ ```
124+
125+ You can also set arguments via environment variable:
126+
127+ ``` bash
128+ BASHUNIT_BOOTSTRAP_ARGS=" staging verbose" bashunit test tests/
129+ ```
130+
131+ See [ Configuration: Bootstrap] ( /configuration#bootstrap ) for more details.
132+
95133### Inline Filter Syntax
96134
97135You can also specify a filter directly in the file path using ` :: ` or ` :line ` syntax:
@@ -197,6 +235,47 @@ bashunit test tests/ --strict
197235```
198236:::
199237
238+ ### Preserve Environment
239+
240+ > ` bashunit test --preserve-env `
241+
242+ Skip loading the ` .env ` file and use the current shell environment only.
243+
244+ By default, bashunit loads variables from ` .env ` which can override environment
245+ variables set in your shell. Use ` --preserve-env ` when you want to:
246+ - Run in CI/CD where environment is pre-configured
247+ - Override ` .env ` values with shell environment variables
248+ - Avoid ` .env ` interfering with your current settings
249+
250+ ::: code-group
251+ ``` bash [Example]
252+ BASHUNIT_SIMPLE_OUTPUT=true ./bashunit test tests/ --preserve-env
253+ ```
254+ :::
255+
256+ ### Login Shell
257+
258+ > ` bashunit test -l|--login `
259+
260+ Run tests in a login shell context by sourcing profile files.
261+
262+ When enabled, bashunit sources the following files (if they exist) before each test:
263+ - ` /etc/profile `
264+ - ` ~/.bash_profile `
265+ - ` ~/.bash_login `
266+ - ` ~/.profile `
267+
268+ Use this when your tests depend on environment setup from login shell profiles, such as:
269+ - PATH modifications
270+ - Shell functions defined in ` .bash_profile `
271+ - Environment variables set during login
272+
273+ ::: code-group
274+ ``` bash [Example]
275+ bashunit test tests/ --login
276+ ```
277+ :::
278+
200279## bench
201280
202281> ` bashunit bench [path] [options] `
@@ -220,11 +299,13 @@ bashunit bench --filter "parse"
220299
221300| Option | Description |
222301| --------| -------------|
223- | ` -e, --env, --boot <file> ` | Load custom env/bootstrap file |
302+ | ` -e, --env, --boot <file> ` | Load custom env/bootstrap file (supports args) |
224303| ` -f, --filter <name> ` | Only run benchmarks matching name |
225304| ` -s, --simple ` | Simple output |
226305| ` --detailed ` | Detailed output (default) |
227306| ` -vvv, --verbose ` | Show execution details |
307+ | ` --preserve-env ` | Skip ` .env ` loading, use shell environment only |
308+ | ` -l, --login ` | Run in login shell context |
228309
229310## doc
230311
0 commit comments