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

Suggesting a doesNotThrowAnyExceptionExcept(...) method #3248

Open
pandoras-toolbox opened this issue Nov 2, 2023 · 3 comments · May be fixed by #3261
Open

Suggesting a doesNotThrowAnyExceptionExcept(...) method #3248

pandoras-toolbox opened this issue Nov 2, 2023 · 3 comments · May be fixed by #3261
Labels
type: new feature A new feature

Comments

@pandoras-toolbox
Copy link

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);
@pbacz
Copy link
Contributor

pbacz commented Nov 8, 2023

@joel-costigliola Is this one free for taking?

@joel-costigliola
Copy link
Member

It is @pbacz 😉

@pbacz
Copy link
Contributor

pbacz commented Nov 12, 2023

@joel-costigliola
Great 👍🏻
I'd like to contribute.
Before I begin I'd like to clarify. When doesNotThrowAnyExceptionExcept(IOException.class) is called and a subclass of IOException is thrown, then the case should pass, shouldn't it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: new feature A new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants