Created
November 23, 2012 06:33
-
-
Save moznion/4134247 to your computer and use it in GitHub Desktop.
Reinventing shouldFail() part2
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 shouldFailBy(Class expected, Closure c) { | |
try { | |
c.call() | |
assert false // Failure | |
} catch (Throwable t) { | |
assert expected.isInstance(t) | |
} | |
} | |
public void test() { | |
shouldFailBy (NullPointerException) {throw new NullPointerException()} | |
shouldFailBy (IllegalAccessError) {throw new IllegalAccessError()} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment