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

Update unit test to avoid deprecated ExpectedException.none() by using Assert.assertThrows() #275

Open
miurahr opened this issue Apr 28, 2024 · 0 comments

Comments

@miurahr
Copy link

miurahr commented Apr 28, 2024

ExpectedException.none() is marked as deprecated but there are so many unit tests which depends on the function.
These cases can be rewritten by using Assert.assertThrows(Class<?> class, ThrowableRunnable run)

There are also Similar deprecation; expectIllegalStateIsNotShowingComponent and expectIllegalStateIsDisabledComponent

These can be implemented as like as followings;


  public static AbstractStringAssert<?> assertThatIllegalStateExceptionCauseIsDisabledComponent(ThrowingRunnable r) {
      Throwable t = Assert.assertThrows(IllegalStateException.class, r);
      return assertThat(t.getMessage()).contains("Expecting component").contains("to be enabled");
  }

  public static AbstractStringAssert<?> assertThatIllegalStateExceptionCauseIsNotShowingComponent(ThrowingRunnable r) {
      Throwable t = Assert.assertThrows(IllegalStateException.class, r);
      return assertThat(t.getMessage()).contains("Expecting component").contains("to be shown on the screen");
  }
  public static AbstractStringAssert<?> assertThatIllegalStateExceptionCauseIsNotResizableComponent(ThrowingRunnable runnable) {
    Throwable t = Assert.assertThrows(IllegalStateException.class, runnable);
    return assertThat(t.getMessage()).contains("Expecting component").contains("to be resizable by the user");
  }
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

No branches or pull requests

1 participant