Decorators

Learn about Decorators and how they can increase the readability of matcher expressions.

A decorator is a wrapper used to wrap a matcher expression that makes it more readable. Let’s explore some of the most common decorators:

is decorator

We can make our matcher expressions more readable in some cases by adding the is decorator. It simply returns the matcher passed to it. In other words, it does nothing.

Sometimes, a little bit of nothing can make your code more readable:

Account account = new Account("my big fat acct"); 
assertThat(account.getName(), is(equalTo("my big fat acct"))); 

Get hands-on with 1400+ tech skills courses.