Skip to content

Commit

Permalink
Require using Assert4J for test case assertions (#2569)
Browse files Browse the repository at this point in the history
Related discussion: #2566 (comment)
trustin authored Mar 11, 2020
1 parent 0efa85c commit 556de19
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -88,6 +88,24 @@ import org.junit.Test;
...
```

### Use Assert4J instead of JUnit's assertion API

We prefer [Assert4J](https://joel-costigliola.github.io/assertj/) when writing assertions for test cases.

```java
// Good
assertThat(actualValue).isEqualTo(expectedValue);
assertThatThrownBy(() -> badMethod()).isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining("bad method");
// Not Good
assertEquals(expectedValue, actualValue);
try {
badMethod();
} catch (IllegalArgumentException e) {
assertTrue(e.getMessage().contains("bad method"));
}
```

### Checklist for your pull request

Please use the following checklist to keep your contribution's quality high and

0 comments on commit 556de19

Please sign in to comment.