Modifies error messages
This commit is contained in:
parent
63b8aa334f
commit
c057808c6e
@ -25,7 +25,7 @@ public class AssertJCustomAssertionsUnitTest {
|
|||||||
assertThat(person).isAdult();
|
assertThat(person).isAdult();
|
||||||
fail();
|
fail();
|
||||||
} catch (AssertionError e) {
|
} catch (AssertionError e) {
|
||||||
org.assertj.core.api.Assertions.assertThat(e).hasMessage("Expected adult but was juvenile");
|
org.assertj.core.api.Assertions.assertThat(e).hasMessage("Expected person to be adult");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ public class AssertJCustomAssertionsUnitTest {
|
|||||||
assertThat(person).hasNickname("John");
|
assertThat(person).hasNickname("John");
|
||||||
fail();
|
fail();
|
||||||
} catch (AssertionError e) {
|
} catch (AssertionError e) {
|
||||||
org.assertj.core.api.Assertions.assertThat(e).hasMessage("Expected nickname John but did not have");
|
org.assertj.core.api.Assertions.assertThat(e).hasMessage("Expected person to have nickname John");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ public class PersonAssert extends AbstractAssert<PersonAssert, Person> {
|
|||||||
public PersonAssert hasFullName(String fullName) {
|
public PersonAssert hasFullName(String fullName) {
|
||||||
isNotNull();
|
isNotNull();
|
||||||
if (!actual.getFullName().equals(fullName)) {
|
if (!actual.getFullName().equals(fullName)) {
|
||||||
failWithMessage("Expected full name %s but was %s", fullName, actual.getFullName());
|
failWithMessage("Expected person to have full name %s but was %s", fullName, actual.getFullName());
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -23,7 +23,7 @@ public class PersonAssert extends AbstractAssert<PersonAssert, Person> {
|
|||||||
public PersonAssert isAdult() {
|
public PersonAssert isAdult() {
|
||||||
isNotNull();
|
isNotNull();
|
||||||
if (actual.getAge() < 18) {
|
if (actual.getAge() < 18) {
|
||||||
failWithMessage("Expected adult but was juvenile");
|
failWithMessage("Expected person to be adult");
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -31,7 +31,7 @@ public class PersonAssert extends AbstractAssert<PersonAssert, Person> {
|
|||||||
public PersonAssert hasNickname(String nickName) {
|
public PersonAssert hasNickname(String nickName) {
|
||||||
isNotNull();
|
isNotNull();
|
||||||
if (!actual.getNicknames().contains(nickName)) {
|
if (!actual.getNicknames().contains(nickName)) {
|
||||||
failWithMessage("Expected nickname %s but did not have", nickName);
|
failWithMessage("Expected person to have nickname %s", nickName);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user