Skip to content

Added control flow in the form of ADT for assertThatCode - #3602

Closed
mipo256 wants to merge 1 commit into
assertj:3.xfrom
mipo256:doesNotThrowAnyExceptionWithReturnValue
Closed

mipo256 wants to merge 1 commit into
assertj:3.xfrom
mipo256:doesNotThrowAnyExceptionWithReturnValue

Conversation

@mipo256

@mipo256 mipo256 commented Sep 9, 2024

Copy link
Copy Markdown
Contributor

This PR brings the ability to control the execution of the code block in a more general manner. For now, assertThatCode creates AbstractTrhowableAssert, which only checks the error thrown by the code block. But sometimes, asserting that the code block did not throw anything and resulted in the particular value is very useful. Example:

String value = "value";

Assertions
    .assertThatCode(() -> value)
    .doesNotThrowAnyException()
    .resultsInValueSatisfying(s -> s.equals(value));

@scordio

scordio commented Sep 9, 2024

Copy link
Copy Markdown
Member

Hi @mipo256, thanks for the PR! As far as I can see, you're trying to address what has been asked at #1652.

However, we have already started working in this direction: see #2519 and CallableAssert_Demo_Test.

In lights of that, I'm closing the PR as a duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants