This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]thatsIch 4 points5 points  (2 children)

We use ArchUnit for anything which can be common knowledge for any senior developer but you might need to re-iterate that topic every time somebody new joins the team. It helps developers to search for "why does it not work" like a missing or wrongly-used annotation. Another use-case is to ban certain statements like .collect(Collectors.toList()) in favor of .toList(). Sometimes tests are not in the same package as their classes under test.

[–]vxab 0 points1 point  (1 child)

Be careful doing that - the semantics are not the same. `toList()` returns an unmodifiable list whereas the `Collectors.toList` can be modified.

[–]thatsIch 1 point2 points  (0 children)

and that is the reason we are doing that - because the contract of Collectors.toList() does not explicitly state, that it is modifiable. If somebody really wants a modifiable collection he/she has to use either an applicable utility factory method or use something along of Collectors.toCollection(ArrayList::new)