Reputation: 108
So a fairly simple one and I have resolved it by using assertEquals instead but just curious to know why this didn't work:
assertThat(list.get(0).getStringValue().equals("1234567811"));
The above line, after checking the variables during debugging, would count as a pass even when the String retrieved did not match.
When I use:
assertEquals(list.get(0).getStringValue(), "1234567811");
It correctly picks up errors.
It was my understanding that assertThat should work for this too so I am curious as to why it doesn't?
Thanks
Upvotes: 3
Views: 1000
Reputation: 759
It looks like AssertJ uses a fluent approach so you would need to do something like
assertThat(list.get(0).getStringValue()).isEqualTo("1234567811");
Upvotes: 2
Reputation: 312
you need to have this form for it to work properly
assertThat(actual, is(equalTo(expected)));
so it should be something like this
assertThat(list.get(0).getStringValue(), is("1234567811"));
or
assertThat(list.get(0).getStringValue(), equalTo("1234567811"));
can read more here
Upvotes: 4