Skip to content

Suggesting a doesNotThrowAnyExceptionExcept(...) method #3248

@pandoras-toolbox

Description

@pandoras-toolbox

Feature summary

As discussed in another issue, here is the suggestion to support being able to ignore certain exceptions when not expecting exceptions.

It would be similar to what can be done with the Selenium API:

   // Waiting 30 seconds for an element to be present on the page, checking
   // for its presence once every 5 seconds.
   Wait<WebDriver> wait = new FluentWait<WebDriver>(driver)
       .withTimeout(Duration.ofSeconds(30L))
       .pollingEvery(Duration.ofSeconds(5L))
       .ignoring(NoSuchElementException.class);

Example

That is how it can look in AssertJ:

assertThatCode(() -> { thisFunctionDoesNothing(); })
                .doesNotThrowAnyExceptionExcept(NoSuchElementException.class, IOException.class);

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions