Package org.fest.assertions
Class BooleanAssert
Understands assertion methods for
Boolean
s and boolean
s. To create a new instance of this class call
Assertions.assertThat(Boolean)
or Assertions.assertThat(boolean)
.-
Field Summary
Fields inherited from class org.fest.assertions.GenericAssert
actual
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
BooleanAssert
(boolean actual) Creates a new
.BooleanAssert
protected
BooleanAssert
(Boolean actual) Creates a new
.BooleanAssert
-
Method Summary
Modifier and TypeMethodDescriptionSets the description of the actual value, to be used in as message of any
thrown when an assertion fails.AssertionError
as
(Description description) Sets the description of the actual value, to be used in as message of any
thrown when an assertion fails.AssertionError
describedAs
(String description) Alias for
, since "as" is a keyword in Groovy.GenericAssert.as(String)
describedAs
(Description description) Alias for
, since "as" is a keyword in Groovy.GenericAssert.as(Description)
doesNotSatisfy
(Condition<Boolean> condition) Verifies that the actualBoolean
does not satisfy the given condition.Alias for
.satisfies(Condition)
isEqualTo
(boolean expected) Verifies that the actualBoolean
is equal to the given one.Verifies that the actualBoolean
value is equal to the given one.void
isFalse()
Verifies that the actualBoolean
value isfalse
.Alias for
.doesNotSatisfy(Condition)
isNotEqualTo
(boolean other) Verifies that the actualBoolean
is not equal to the given one.isNotEqualTo
(Boolean other) Verifies that the actualBoolean
is not equal to the given one.Verifies that the actualBoolean
is notnull
.isNotSameAs
(Boolean other) Verifies that the actualBoolean
is not the same object as the given one.Verifies that the actualBoolean
is the same object as the given one.void
isTrue()
Verifies that the actualBoolean
value istrue
.overridingErrorMessage
(String message) Replaces the default message displayed in case of a failure with the given one.Verifies that the actualBoolean
satisfies the given condition.Methods inherited from class org.fest.assertions.GenericAssert
assertDoesNotSatisfy, assertEqualTo, assertIs, assertIsNot, assertNotEqualTo, assertNotNull, assertNotSameAs, assertSameAs, assertSatisfies, isNull
Methods inherited from class org.fest.assertions.Assert
customErrorMessage, description, description, description, equals, fail, fail, failIfCustomMessageIsSet, failIfCustomMessageIsSet, failure, formattedErrorMessage, hashCode, rawDescription, replaceDefaultErrorMessagesWith
-
Constructor Details
-
BooleanAssert
protected BooleanAssert(boolean actual) Creates a new
.BooleanAssert
- Parameters:
actual
- the actual value to verify.
-
BooleanAssert
Creates a new
.BooleanAssert
- Parameters:
actual
- the actual value to verify.
-
-
Method Details
-
as
Sets the description of the actual value, to be used in as message of any
thrown when an assertion fails. This method should be called before any assertion method, otherwise any assertion failure will not show the provided description.AssertionError
For example:
assertThat(val).as("name").isEqualTo("Frodo");
- Specified by:
as
in classGenericAssert<Boolean>
- Parameters:
description
- the description of the actual value.- Returns:
- this assertion object.
-
describedAs
Alias for
, since "as" is a keyword in Groovy. This method should be called before any assertion method, otherwise any assertion failure will not show the provided description.GenericAssert.as(String)
For example:
assertThat(val).describedAs("name").isEqualTo("Frodo");
- Specified by:
describedAs
in classGenericAssert<Boolean>
- Parameters:
description
- the description of the actual value.- Returns:
- this assertion object.
-
as
Sets the description of the actual value, to be used in as message of any
thrown when an assertion fails. This method should be called before any assertion method, otherwise any assertion failure will not show the provided description.AssertionError
For example:
assertThat(val).as(new BasicDescription("name")).isEqualTo("Frodo");
- Specified by:
as
in classGenericAssert<Boolean>
- Parameters:
description
- the description of the actual value.- Returns:
- this assertion object.
-
describedAs
Alias for
, since "as" is a keyword in Groovy. This method should be called before any assertion method, otherwise any assertion failure will not show the provided description.GenericAssert.as(Description)
For example:
assertThat(val).describedAs(new BasicDescription("name")).isEqualTo("Frodo");
- Specified by:
describedAs
in classGenericAssert<Boolean>
- Parameters:
description
- the description of the actual value.- Returns:
- this assertion object.
-
isTrue
public void isTrue()Verifies that the actualBoolean
value istrue
.- Throws:
AssertionError
- if the actualBoolean
value isfalse
.
-
isFalse
public void isFalse()Verifies that the actualBoolean
value isfalse
.- Throws:
AssertionError
- if the actualBoolean
value istrue
.
-
isEqualTo
Verifies that the actualBoolean
is equal to the given one.- Parameters:
expected
- the givenboolean
to compare the actualBoolean
to.- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actualBoolean
is not equal to the given one.
-
isEqualTo
Verifies that the actualBoolean
value is equal to the given one.- Specified by:
isEqualTo
in classGenericAssert<Boolean>
- Parameters:
expected
- the givenBoolean
value to compare the actualBoolean
to.- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actualBoolean
value is not equal to the given one.- Since:
- 1.3
-
isNotEqualTo
Verifies that the actualBoolean
is not equal to the given one.- Parameters:
other
- the givenboolean
to compare the actualBoolean
to.- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actualBoolean
is equal to the given one.
-
isNotEqualTo
Verifies that the actualBoolean
is not equal to the given one.- Specified by:
isNotEqualTo
in classGenericAssert<Boolean>
- Parameters:
other
- the givenBoolean
to compare the actualBoolean
to.- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actualBoolean
value is equal to the given one.- Since:
- 1.3
-
satisfies
Verifies that the actualBoolean
satisfies the given condition.- Specified by:
satisfies
in classGenericAssert<Boolean>
- Parameters:
condition
- the given condition.- Returns:
- this assertion object.
- Throws:
NullPointerException
- if the given condition isnull
.AssertionError
- if the actualBoolean
does not satisfy the given condition.- Since:
- 1.3
- See Also:
-
doesNotSatisfy
Verifies that the actualBoolean
does not satisfy the given condition.- Specified by:
doesNotSatisfy
in classGenericAssert<Boolean>
- Parameters:
condition
- the given condition.- Returns:
- this assertion object.
- Throws:
NullPointerException
- if the given condition isnull
.AssertionError
- if the actual value does satisfies the given condition.- Since:
- 1.3
- See Also:
-
is
Alias for
.satisfies(Condition)
- Specified by:
is
in classGenericAssert<Boolean>
- Parameters:
condition
- the given condition.- Returns:
- this assertion object.
- Throws:
NullPointerException
- if the given condition isnull
.AssertionError
- if the actualBoolean
does not satisfy the given condition.- Since:
- 1.3
-
isNot
Alias for
.doesNotSatisfy(Condition)
- Specified by:
isNot
in classGenericAssert<Boolean>
- Parameters:
condition
- the given condition.- Returns:
- this assertion object.
- Throws:
NullPointerException
- if the given condition isnull
.AssertionError
- if the actualBoolean
does not satisfy the given condition.- Since:
- 1.3
-
isNotNull
Verifies that the actualBoolean
is notnull
.- Specified by:
isNotNull
in classGenericAssert<Boolean>
- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actualBoolean
value isnull
.- Since:
- 1.3
-
isSameAs
Verifies that the actualBoolean
is the same object as the given one.- Specified by:
isSameAs
in classGenericAssert<Boolean>
- Parameters:
expected
- the givenBoolean
to compare the actualBoolean
to.- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actualBoolean
value is not the same as the given one.- Since:
- 1.3
-
isNotSameAs
Verifies that the actualBoolean
is not the same object as the given one.- Specified by:
isNotSameAs
in classGenericAssert<Boolean>
- Parameters:
other
- the givenBoolean
to compare the actualBoolean
to.- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actualBoolean
value is the same as the given one.- Since:
- 1.3
-
overridingErrorMessage
Replaces the default message displayed in case of a failure with the given one.For example, the following assertion:
assertThat("Hello").isEqualTo("Bye");
will fail with the default message "expected:<'[Bye]'> but was:<'[Hello]'>."We can replace this message with our own:
assertThat("Hello").overridingErrorMessage("'Hello' should be equal to 'Bye'").isEqualTo("Bye");
in this case, the assertion will fail showing the message "'Hello' should be equal to 'Bye'".- Specified by:
overridingErrorMessage
in classGenericAssert<Boolean>
- Parameters:
message
- the given error message, which will replace the default one.- Returns:
- this assertion.
-