diff --git a/.editorconfig b/.editorconfig index 2efdbab8..02464a36 100644 --- a/.editorconfig +++ b/.editorconfig @@ -26,5 +26,5 @@ indent_size = 2 [{Makefile,**.mk,.git*}] indent_style = tab -[{tests/acceptance/**.sh,src/console_header.sh}] +[{tests/acceptance/**.sh,src/console_header.sh,docs/command-line.md}] indent_size = unset diff --git a/.env.example b/.env.example index 5d454a26..b9cd8c9d 100644 --- a/.env.example +++ b/.env.example @@ -1,6 +1,6 @@ BASHUNIT_DEFAULT_PATH= BASHUNIT_DEV_LOG= -BASHUNIT_LOAD_FILE= +BASHUNIT_BOOTSTRAP= BASHUNIT_LOG_JUNIT= BASHUNIT_REPORT_HTML= diff --git a/CHANGELOG.md b/CHANGELOG.md index 54153a48..637b410d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,7 +21,7 @@ - log - Add default env values: - `BASHUNIT_DEFAULT_PATH="tests"` - - `BASHUNIT_LOAD_FILE="tests/bootstrap.sh"` + - `BASHUNIT_BOOTSTRAP="tests/bootstrap.sh"` - Add check that git is installed to `install.sh` - Add `-vvv|--verbose` to display internal details of each test - Fixed `-S|--stop-on-failure` behaviour @@ -43,7 +43,7 @@ - Added failing tests after running the entire suite - Improved runtime errors handling - Simplified total tests display on the header -- Renamed `BASHUNIT_TESTS_ENV` to `BASHUNIT_LOAD_FILE` +- Renamed `BASHUNIT_TESTS_ENV` to `BASHUNIT_BOOTSTRAP` - Better handler runtime errors - Display failing tests after running the entire suite - Added defer expressions with `eval` when using standalone assertions diff --git a/bashunit b/bashunit index bd1c5a12..fe28d2c1 100755 --- a/bashunit +++ b/bashunit @@ -70,7 +70,7 @@ while [[ $# -gt 0 ]]; do --no-parallel) export BASHUNIT_PARALLEL_RUN=false ;; - -e|--env|--load) + -e|--env|--boot) # shellcheck disable=SC1090 source "$2" shift @@ -108,7 +108,7 @@ while [[ $# -gt 0 ]]; do done # shellcheck disable=SC1090 -[[ -f "$BASHUNIT_LOAD_FILE" ]] && source "$BASHUNIT_LOAD_FILE" +[[ -f "$BASHUNIT_BOOTSTRAP" ]] && source "$BASHUNIT_BOOTSTRAP" set +eu diff --git a/docs/blog/2024-10-01-release-0-17.md b/docs/blog/2024-10-01-release-0-17.md index a08d8fd2..5ddd1dae 100644 --- a/docs/blog/2024-10-01-release-0-17.md +++ b/docs/blog/2024-10-01-release-0-17.md @@ -73,7 +73,7 @@ Testing.php:3:Method Testing::bar() has no return type specified. * Add support for Alpine (Linux Distro) in [#331](https://github.com/TypedDevs/bashunit/pull/331) * Improve debug output [#332](https://github.com/TypedDevs/bashunit/pull/332) -* Improve loading extra file with BASHUNIT_LOAD_FILE [#330](https://github.com/TypedDevs/bashunit/pull/330) +* Enable loading extra file with BASHUNIT_BOOTSTRAP [#330](https://github.com/TypedDevs/bashunit/pull/330) * Remove deprecated assertions [#344](https://github.com/TypedDevs/bashunit/pull/344) * Some required dependencies now optional: perl, coreutils [#345](https://github.com/TypedDevs/bashunit/pull/345) * Upgrade and install script can now use `wget` if `curl` is not installed [#345](https://github.com/TypedDevs/bashunit/pull/345) diff --git a/docs/command-line.md b/docs/command-line.md index 7ae3c0d7..adbd4696 100644 --- a/docs/command-line.md +++ b/docs/command-line.md @@ -45,32 +45,35 @@ Run a core assert function standalone without a test context. Read more: [Standa ``` ::: -## Debug +## Bootstrap -> `bashunit --debug ` +> `bashunit -e|--env|--boot "file path"` -Enables a shell mode in which all executed commands are printed to the terminal, -or printed into a file if this is specified. +Load a custom file, overriding the existing `.env` variables or loading a bootstrap file. -Printing every command as executed may help you visualize the script's control flow if it is not working as expected. +> You can use `BASHUNIT_BOOTSTRAP` option in your [configuration](/configuration#bootstrap). ::: code-group -```bash [Example] -./bashunit --debug local/debug.sh +```bash [Example: --boot] +./bashunit tests --boot tests/globals.sh +``` +```bash [Example: --env] +./bashunit tests --env .env.tests ``` ::: -## Environment +## Debug -> `bashunit -e|--env|--load "file path"` +> `bashunit --debug ` -Load a custom file, overriding the existing `.env` variables or loading a file with global functions. +Enables a shell mode in which all executed commands are printed to the terminal, +or printed into a file if this is specified. -You can use `BASHUNIT_LOAD_FILE` option in your [configuration](/configuration#tests-env). +Printing every command as executed may help you visualize the script's control flow if it is not working as expected. ::: code-group ```bash [Example] -./bashunit tests --env .env.tests +./bashunit --debug local/debug.sh ``` ::: @@ -82,12 +85,12 @@ Filters the tests to be run based on the `test name`. ::: code-group ```bash [Example] -# run all test functions including "something" in it's name +# run all test functions including "something" in the name ./bashunit ./tests --filter "something" ``` ::: -## Logging +## JUnit Logging > `bashunit -l|--log-junit ` @@ -97,6 +100,27 @@ Creates a report XML file that follows the JUnit XML format and contains informa ```bash [Example] ./bashunit ./tests --log-junit log-junit.xml ``` +```xml [log-junit.xml] + + + + + + + + ... etc +``` ::: ## Parallel @@ -121,7 +145,7 @@ You can use `BASHUNIT_PARALLEL_RUN` option in your [configuration](/configuratio If parallel testing is enabled by default or within a script, you can disable it using the --no-parallel option. This is useful if you need to run tests in sequence or if parallel execution is causing issues during debugging. -## Report +## HTML report > `bashunit -r|--report-html ` @@ -131,13 +155,67 @@ Creates a report HTML file that contains information about the test results of y ```bash [Example] ./bashunit ./tests --report-html report.html ``` + +```html [report.html] + + + + + + Test Report + + + +

Test Report

+ + + + + + + + + + + + + + + + + + + + + + + +
Total TestsPassedFailedIncompleteSkippedSnapshotTime (ms)
3403280101146811
+

Time: 46811 ms

+

File: tests/acceptance/bashunit_direct_fn_call_test.sh

+ + + + + ... etc +``` ::: ## Output > `bashunit -s|--simple` > -> `bashunit -vvv|--detailed` +> `bashunit --detailed` [Default] Enables simplified or verbose output to the console. @@ -149,15 +227,18 @@ You can use `BASHUNIT_SIMPLE_OUTPUT` option in your [configuration](/configurati to choose the default output display. ::: code-group -```[Output] -........ -``` ```bash [Example] ./bashunit ./tests --simple ``` +```[Output] +........ +``` ::: ::: code-group +```bash [Example] +./bashunit ./tests --detailed +``` ```[Output] Running tests/functional/logic_test.sh ✓ Passed: Other way of using the exit code @@ -169,9 +250,6 @@ Running tests/functional/logic_test.sh ✓ Passed: Text should not contain ✓ Passed: Text should not match a regular expression ``` -```bash [Example] -./bashunit ./tests --detailed -``` ::: ## Stop on failure @@ -202,6 +280,45 @@ to make this behavior permanent. ```bash [Example] ./bashunit --verbose ``` +```bash [Output] +bashunit - 0.17.0 | Tests: ~333 +######################################################################################################################################## +Filter: None +Total files: 36 +Test files: +- tests/acceptance/bashunit_direct_fn_call_test.sh +- tests/acceptance/bashunit_execution_error_test.sh +- tests/acceptance/bashunit_fail_test.sh +- tests/acceptance/bashunit_find_tests_command_line_test.sh +- tests/acceptance/bashunit_log_junit_test.sh +- ... etc +........................................................................................................................................ +BASHUNIT_DEFAULT_PATH: tests +BASHUNIT_DEV_LOG: dev.log +BASHUNIT_BOOTSTRAP: tests/bootstrap.sh +BASHUNIT_LOG_JUNIT: local/log-junit.xml +BASHUNIT_REPORT_HTML: local/report.html +BASHUNIT_PARALLEL_RUN: false +BASHUNIT_SHOW_HEADER: true +BASHUNIT_HEADER_ASCII_ART: false +BASHUNIT_SIMPLE_OUTPUT: false +BASHUNIT_STOP_ON_FAILURE: false +BASHUNIT_SHOW_EXECUTION_TIME: true +BASHUNIT_DEV_MODE: true +BASHUNIT_VERBOSE: true +######################################################################################################################################## + +Running tests/acceptance/bashunit_direct_fn_call_test.sh +======================================================================================================================================== +File: tests/acceptance/bashunit_direct_fn_call_test.sh +Function: test_bashunit_direct_fn_call_passes +Duration: 48 ms +##ASSERTIONS_FAILED=0##ASSERTIONS_PASSED=1##ASSERTIONS_SKIPPED=0##ASSERTIONS_INCOMPLETE=0##ASSERTIONS_SNAPSHOT=0##TEST_OUTPUT=## +---------------------------------------------------------------------------------------------------------------------------------------- +✓ Passed: Bashunit direct fn call passes 48 ms +======================================================================================================================================== +... etc +``` ::: ## Version @@ -211,12 +328,12 @@ to make this behavior permanent. Displays the current version of **bashunit**. ::: code-group -```-vue [Output] -bashunit - {{ pkg.version }} -``` ```bash [Example] ./bashunit --version ``` +```-vue [Output] +bashunit - {{ pkg.version }} +``` ::: ## Upgrade @@ -229,6 +346,9 @@ Upgrade **bashunit** to latest version. ```bash [Example] ./bashunit --upgrade ``` +```bash [Output] +> You are already on latest version +``` ::: ## Help @@ -238,6 +358,9 @@ Upgrade **bashunit** to latest version. Displays a help message with all allowed arguments and options. ::: code-group +```bash [Example] +./bashunit --help +``` ```[Output] bashunit [arguments] [options] @@ -250,9 +373,6 @@ Options: [...] ``` -```bash [Example] -./bashunit --help -``` :::
Test Name