-
Notifications
You must be signed in to change notification settings - Fork 634
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Stacktrace Substring Matching to Throwable Matchers (#3998)
This PR introduces the ability to match substrings and regular expressions in the stacktrace of a `Throwable` in the Kotest assertions library. This feature can be useful when writing tests that need to assert on specific parts of a stacktrace. Changes: 1. Added two new infix functions `shouldHaveStacktraceContaining` and `shouldNotHaveStacktraceContaining` to the `Throwable` class. These functions accept a `String` or `Regex` and use it to match against the stacktrace of the `Throwable`. 2. Added corresponding matcher functions `haveStacktraceContaining` that create a `Matcher<Throwable>` to perform the actual matching logic. 3. Added tests for these new functions in `ThrowableMatchersTest.kt`. This enhancement provides more flexibility when writing tests involving exceptions and their stacktraces. --------- Co-authored-by: Sam <sam@sksamuel.com> Co-authored-by: Emil Kantis <emil.kantis@protonmail.com>
- Loading branch information
1 parent
2d3cbb6
commit 9b00d42
Showing
3 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters