6

It looks very cool

assertThat(yoda).is(jedi);

until you don't know what is yoda and jedi. But suppose

yoda instanceof Person

where

interface Person {
    boolean isJedi();
}

Then how actually check isJedi with AssertJ?

In conventional JUnit I would write

assertTrue( yoda.isJedi() );

but what in AssertJ?

Dims
  • 47,675
  • 117
  • 331
  • 600

2 Answers2

13
assertThat(yoda.isJedi()).isTrue()
JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255
  • Great! But why examples demonstrate different? May be I can rapidly compose Condition for yoda somehow? – Dims Aug 30 '16 at 13:24
  • Conditions are used to express more complex checks that you want to reuse, in your case it is a simple boolean check that is (hopefully) already supported. – Joel Costigliola Aug 31 '16 at 11:57
1

assertThat(yoda.isJedi()).isEqualTo(true);