Created
November 23, 2012 06:32
-
-
Save moznion/4134246 to your computer and use it in GitHub Desktop.
Reinventing shouldFail() part1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import groovy.util.GroovyTestCase | |
public class Test extends GroovyTestCase { | |
private shouldError(Closure c) { | |
try { | |
c.call() | |
assert false // Failure | |
} catch (Error expected) { | |
assert true //Successful | |
} | |
} | |
private shouldException(Closure c) { | |
try { | |
c.call() | |
assert false // Failure | |
} catch (Exception expected) { | |
assert true //Successful | |
} | |
} | |
public void test() { | |
shouldError { throw new IllegalAccessError() } | |
shouldException { throw new NullPointerException() } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment