Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to test caught exceptions (fixes #591) #813

Merged
merged 3 commits into from
May 29, 2022

Commits on May 29, 2022

  1. make Formatters.formatNamesOf(..) compatible with bound types

    At the moment if there is some sort of `Collection<Class<? extends SomeBound>>` instead of `Collection<Class<?>>` then `Formatters.formatNamesOf(collection)` does not compile, because `Class<? extends SomeBound>` counts as subtype of `Class<?>`. Thus, we change the signature to allow `? extends Class<?>` to make this work out of the box with bounded types.
    
    Signed-off-by: Peter Gafert <[email protected]>
    codecholeric committed May 29, 2022
    Configuration menu
    Copy the full SHA
    1aa4028 View commit details
    Browse the repository at this point in the history
  2. move inner assertion classes out of ..testutil.Assertions

    It is more consistent if all concrete assertion classes reside in `testutil.assertion`, instead of just some of them.
    
    Signed-off-by: Peter Gafert <[email protected]>
    codecholeric committed May 29, 2022
    Configuration menu
    Copy the full SHA
    88e7ec5 View commit details
    Browse the repository at this point in the history
  3. Add support to test caught exceptions

    This will add `TryCatchBlocks` to the ArchUnit core and introduce `JavaCodeUnit.getTryCatchBlocks()` to examine try-catch blocks that have been parsed from the bytecode of a method or constructor. We also add an extension `JavaAccess.getContainingTryBlocks()` to make it easy to verify that certain accesses in code are wrapped into certain try-catch blocks (e.g. "whenever method x is called there should be a try-catch block to handle exception case y").
    
    Signed-off-by: Krzysztof Sierszeń <[email protected]>
    Signed-off-by: Peter Gafert <[email protected]>
    crizzis authored and codecholeric committed May 29, 2022
    Configuration menu
    Copy the full SHA
    e0e0c65 View commit details
    Browse the repository at this point in the history