|
| 1 | +--- |
| 2 | +date: '2025-06-01' |
| 3 | +title: 'Release 0.20' |
| 4 | +description: 'New spy assertions, subshell support, argument interpolation in test names, Windows parallel test execution, and performance improvements across the board.' |
| 5 | +coverUrl: '/imgs/2025-06-01/interpolation-data-provider.png' |
| 6 | +coverAlt: 'Data provider with interpolate args' |
| 7 | + |
| 8 | +aside: false |
| 9 | +--- |
| 10 | + |
| 11 | +# {{ $frontmatter.title }} |
| 12 | + |
| 13 | +<time>{{ $formatDate($frontmatter.date) }}</time> |
| 14 | + |
| 15 | +## 🐛 Bugfix |
| 16 | + |
| 17 | +### Test doubles used in subshells |
| 18 | + |
| 19 | +Assertions on spies now work even when the call happens inside a subshell. |
| 20 | + |
| 21 | +::: code-group |
| 22 | +```bash [Example] |
| 23 | +function test_spy_in_subshell() { |
| 24 | + spy date |
| 25 | + |
| 26 | + ( |
| 27 | + date |
| 28 | + ) |
| 29 | + |
| 30 | + assert_have_been_called date |
| 31 | +} |
| 32 | +``` |
| 33 | +::: |
| 34 | + |
| 35 | +## 🔧 New features |
| 36 | + |
| 37 | +### Interpolating arguments in test names |
| 38 | + |
| 39 | +Data providers can now interpolate their arguments directly into the test name. Combine it with the new `@` prefix to improve readability. |
| 40 | + |
| 41 | +::: code-group |
| 42 | +```bash [example_test.sh] |
| 43 | +# @data_provider fizz_numbers |
| 44 | +function test_returns_fizz_when_multiple_of_::1::_like_::2::_given() { |
| 45 | + # ... |
| 46 | +} |
| 47 | + |
| 48 | +function fizz_numbers() { |
| 49 | + echo 3 4 |
| 50 | + echo 3 6 |
| 51 | +} |
| 52 | +``` |
| 53 | +```[Output] |
| 54 | +Running example_test.sh |
| 55 | +✓ Passed: Returns fizz when multiple of '3' like '4' given |
| 56 | +✓ Passed: Returns fizz when multiple of '3' like '6' given |
| 57 | +``` |
| 58 | +::: |
| 59 | + |
| 60 | +### New assertions for test doubles |
| 61 | + |
| 62 | +You can ensure that a spy was **not** executed using `assert_not_called` and check arguments for specific invocations with an optional index in `assert_have_been_called_with`. |
| 63 | + |
| 64 | +::: code-group |
| 65 | +```bash [Example] |
| 66 | +function test_success() { |
| 67 | + spy ps |
| 68 | + |
| 69 | + ps foo |
| 70 | + ps bar |
| 71 | + |
| 72 | + assert_have_been_called_with "foo" ps 1 |
| 73 | + assert_have_been_called_with "bar" ps 2 |
| 74 | + assert_not_called ls |
| 75 | +} |
| 76 | +``` |
| 77 | +::: |
| 78 | + |
| 79 | +### Snapshot comparison ignoring colors |
| 80 | + |
| 81 | +`assert_match_snapshot_ignore_colors` allows validating colored output without caring about ANSI codes. |
| 82 | + |
| 83 | +::: code-group |
| 84 | +```bash [Example] |
| 85 | +function test_success() { |
| 86 | + assert_match_snapshot_ignore_colors "$(printf '\e[31mHello\e[0m World!')" |
| 87 | +} |
| 88 | +``` |
| 89 | +::: |
| 90 | + |
| 91 | +### Parallel tests on Windows |
| 92 | + |
| 93 | +Parallel execution is now enabled on Windows, greatly reducing running time for large suites. |
| 94 | + |
| 95 | +## 🌾 Miscellaneous |
| 96 | + |
| 97 | +* Deprecate `# data_provider` in favor of `# @data_provider` |
| 98 | +* Improve `find_total_tests` and `runner::parse_result_sync` performance |
| 99 | + |
| 100 | +--- |
| 101 | + |
| 102 | +See the full changelog in <a href="https://github.com/TypedDevs/bashunit/blob/main/CHANGELOG.md">GitHub</a> |
0 commit comments