Top "Assertj" questions

AssertJ provides a set of strongly-typed assertions to use for unit testing (either with JUnit or TestNG).

AnyString() as parameter for unit test

I have to deal with a legacy application that has no tests. So before I begin refactoring I want to …

java junit mockito powermock assertj
Can you add a custom message to AssertJ assertThat?

We have a test suite that primarily uses JUnit assertions with Hamcrest matchers. One of our team started experimenting with …

java unit-testing junit assertj
How to compare recursively ignoring given fields using assertJ?

AssertJ has isEqualToIgnoringGivenFields and isEqualToComparingFieldByFieldRecursively. But, there is no way I can compare two objects recursively by ignoring some fields. …

java unit-testing assertj
Asserting properties on list elements with assertJ

I have a working hamcrest assertion: assertThat(mylist, contains( containsString("15"), containsString("217"))); The intended behavior is: mylist == asList("Abcd15", "217aB") => …

java junit assertj
How to assert that two Lists<String> are equal, ignoring order

I am using AssertJ and I am trying to assert that two List<String> contain same strings, ignoring …

java assertj
Testing content of list ignoring some of the fields

I have a scenario where I receive a list from a method call and I would like to assert that …

java unit-testing hamcrest assertj
how to use assertj extracting map property

I am using AssertJ. I have a class like MyObj. And I have a List of MyObj. Class MyObj { ... Map&…

java junit assert assertj
How to perform deeper matching of keys and values with assertj

Say I have a class like this: public class Character { public Character(String name){ this.name = name; } private String name; …

java assertj
AssertJ: For a Pojo how to check each nested Property/Field in one chained sentence

Having a POJO such as: public class ClientWebRequest { private URI uri; private HttpMethod httpMethod; private final Header header; private final …

junit assertj
Is it possible to exclude some fields from assertJ usingFieldByFieldElementComparator?

How to achieve the below: List<Data> streams = new ArrayList<>(); assertThat(streams).usingFieldByFieldElementComparatorIgnoringGivenFields("createdOn").containsOnly(data1, …

java assertions assertj