org.fest.assertions
Class PrimitiveAssert

java.lang.Object
  extended by org.fest.assertions.Assert
      extended by org.fest.assertions.PrimitiveAssert
Direct Known Subclasses:
BooleanAssert, ByteAssert, CharAssert, DoubleAssert, FloatAssert, IntAssert, LongAssert, ShortAssert

public abstract class PrimitiveAssert
extends Assert

Understands a template for assertion methods for primitive values.

Author:
Yvonne Wang

Constructor Summary
PrimitiveAssert()
           
 
Method Summary
protected abstract  PrimitiveAssert as(Description description)
          Sets the description of the actual value, to be used in as message of any AssertionError thrown when an assertion fails.
protected abstract  PrimitiveAssert as(String description)
          Sets the description of the actual value, to be used in as message of any AssertionError thrown when an assertion fails.
protected abstract  PrimitiveAssert describedAs(Description description)
          Alias for as(Description), since "as" is a keyword in Groovy.
protected abstract  PrimitiveAssert describedAs(String description)
          Alias for as(String), since "as" is a keyword in Groovy.
protected abstract  PrimitiveAssert overridingErrorMessage(String message)
          Replaces the default message displayed in case of a failure with the given one.
 
Methods inherited from class org.fest.assertions.Assert
customErrorMessage, description, description, description, equals, fail, fail, failIfCustomMessageIsSet, failIfCustomMessageIsSet, failure, formattedErrorMessage, hashCode, rawDescription, replaceDefaultErrorMessagesWith
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PrimitiveAssert

public PrimitiveAssert()
Method Detail

as

protected abstract PrimitiveAssert as(String description)
Sets the description of the actual value, to be used in as message of any AssertionError thrown when an assertion fails. This method should be called before any assertion method, otherwise any assertion failure will not show the provided description.

For example:

 assertThat(value).as("Some value").isEqualTo(otherValue);
 

Parameters:
description - the description of the actual value.
Returns:
this assertion object.

describedAs

protected abstract PrimitiveAssert describedAs(String description)
Alias for as(String), 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.

For example:

 assertThat(value).describedAs("Some value").isEqualTo(otherValue);
 

Parameters:
description - the description of the actual value.
Returns:
this assertion object.

as

protected abstract PrimitiveAssert as(Description description)
Sets the description of the actual value, to be used in as message of any AssertionError thrown when an assertion fails. This method should be called before any assertion method, otherwise any assertion failure will not show the provided description.

For example:

 assertThat(val).as(new BasicDescription("name")).isEqualTo("Frodo");
 

Parameters:
description - the description of the actual value.
Returns:
this assertion object.

describedAs

protected abstract PrimitiveAssert describedAs(Description description)
Alias for as(Description), 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.

For example:

 assertThat(val).describedAs(new BasicDescription("name")).isEqualTo("Frodo");
 

Parameters:
description - the description of the actual value.
Returns:
this assertion object.

overridingErrorMessage

protected abstract PrimitiveAssert overridingErrorMessage(String message)
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'".

Parameters:
message - the given error message, which will replace the default one.
Returns:
this assertion.
Since:
1.2


Copyright © 2007-2010 FEST (Fixtures for Easy Software Testing). All Rights Reserved.