com.google.common.testing
Class GuavaAsserts

java.lang.Object
  extended by com.google.common.testing.GuavaAsserts

@Beta
@GwtCompatible
public final class GuavaAsserts
extends Object

Contains additional assertion methods not found in JUnit.

Since:
10.0
Author:
Kevin Bourillion

Nested Class Summary
static class GuavaAsserts.TestAssertionFailure
          An error thrown when test assertions are shown to be invalid.
 
Method Summary
static void assertEquals(Object expected, Object actual)
          Assert the equality of two objects
static void assertEquals(String message, Object o1, Object o2)
          Assert the equality of two objects
static void assertTrue(boolean condition)
          Test the condition and throw a failure exception if false with a stock message.
static void assertTrue(String message, boolean condition)
          Test the condition and throw a failure exception if false with a stock message.
static void checkEqualsAndHashCodeMethods(String message, Object lhs, Object rhs, boolean expectedResult)
          Utility for testing equals() and hashCode() results at once.
static void fail()
          Fail with an RuntimeException.
static void fail(String message)
          Fail with an RuntimeException and a message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

checkEqualsAndHashCodeMethods

public static void checkEqualsAndHashCodeMethods(String message,
                                                 Object lhs,
                                                 Object rhs,
                                                 boolean expectedResult)
Utility for testing equals() and hashCode() results at once. Tests that lhs.equals(rhs) matches expectedResult, as well as rhs.equals(lhs). Also tests that hashCode() return values are equal if expectedResult is true. (hashCode() is not tested if expectedResult is false, as unequal objects can have equal hashCodes.)

Parameters:
lhs - An Object for which equals() and hashCode() are to be tested.
rhs - As lhs.
expectedResult - True if the objects should compare equal, false if not.

fail

public static void fail()
Fail with an RuntimeException.

Throws:
RuntimeException - always

fail

public static void fail(String message)
Fail with an RuntimeException and a message.

Throws:
RuntimeException - always

assertTrue

public static void assertTrue(boolean condition)
Test the condition and throw a failure exception if false with a stock message.


assertTrue

public static void assertTrue(String message,
                              boolean condition)
Test the condition and throw a failure exception if false with a stock message.


assertEquals

public static void assertEquals(Object expected,
                                Object actual)
Assert the equality of two objects


assertEquals

public static void assertEquals(String message,
                                Object o1,
                                Object o2)
Assert the equality of two objects



Copyright © 2010-2011. All Rights Reserved.