assertj / assertj/assertj-swing

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

Open
#275 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
121
Forks
52
PR merge metrics
No merged PRs in 30d

Description

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");
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.