groovy.test
Class GroovyAssert

java.lang.Object
  extended by groovy.test.GroovyAssert

public class GroovyAssert
extends Object


Constructor Summary
GroovyAssert()
           
 
Method Summary
static Throwable shouldFail(Class clazz, groovy.lang.Closure code)
          Asserts that the given code closure fails when it is evaluated and that a particular type of exception is thrown.
static Throwable shouldFail(groovy.lang.Closure code)
          Asserts that the given code closure fails when it is evaluated
static Throwable shouldFailWithCause(Class expectedCause, groovy.lang.Closure code)
          Asserts that the given code closure fails when it is evaluated and that a particular Exception type can be attributed to the cause.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GroovyAssert

public GroovyAssert()
Method Detail

shouldFail

public static Throwable shouldFail(groovy.lang.Closure code)
Asserts that the given code closure fails when it is evaluated

Parameters:
code - the code expected to fail
Returns:
the caught exception

shouldFail

public static Throwable shouldFail(Class clazz,
                                   groovy.lang.Closure code)
Asserts that the given code closure fails when it is evaluated and that a particular type of exception is thrown.

Parameters:
clazz - the class of the expected exception
code - the closure that should fail
Returns:
the caught exception

shouldFailWithCause

public static Throwable shouldFailWithCause(Class expectedCause,
                                            groovy.lang.Closure code)
Asserts that the given code closure fails when it is evaluated and that a particular Exception type can be attributed to the cause. The expected exception class is compared recursively with any nested exceptions using getCause() until either a match is found or no more nested exceptions exist.

If a match is found, the matching exception is returned otherwise the method will fail.

Parameters:
expectedCause - the class of the expected exception
code - the closure that should fail
Returns:
the cause

Copyright © 2003-2012 The Codehaus. All rights reserved.