junit
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| junit [2020/03/11 08:39] – kalaschnikow | junit [2020/03/11 08:40] (current) – kalaschnikow | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== JUnit ====== | ||
| + | [[JUnit 5]] | ||
| + | |||
| + | |||
| + | ===== Articles ===== | ||
| + | |||
| + | [[JUnit Best Practices]] by Kyle Blaney | ||
| + | |||
| + | |||
| + | ===== AssertJ ===== | ||
| + | A better alternative to JUnit assertions is : [[http:// | ||
| + | |||
| + | Examples for '' | ||
| + | <code java> | ||
| + | assertThat(frodo.age).isEqualTo(33); | ||
| + | assertThat(frodo.getName()).isEqualTo(" | ||
| + | |||
| + | assertThat(frodo).isIn(fellowshipOfTheRing); | ||
| + | assertThat(frodo).isIn(sam, | ||
| + | assertThat(sauron).isNotIn(fellowshipOfTheRing); | ||
| + | |||
| + | assertThat(frodo).matches(p -> p.age > 30 && p.getRace() == HOBBIT); | ||
| + | assertThat(frodo.age).matches(p -> p > 30); | ||
| + | </ | ||
| + | |||
| + | Examples for '' | ||
| + | <code java> | ||
| + | then(frodo.age).isEqualTo(33); | ||
| + | then(frodo.getName()).isEqualTo(" | ||
| + | |||
| + | then(frodo).isIn(fellowshipOfTheRing); | ||
| + | then(frodo).isIn(sam, | ||
| + | then(sauron).isNotIn(fellowshipOfTheRing); | ||
| + | |||
| + | then(frodo).matches(p -> p.age > 30 && p.getRace() == HOBBIT); | ||
| + | then(frodo.age).matches(p -> p > 30); | ||
| + | </ | ||
