Skip to content

Commit

Permalink
Handle throwables in shouldThrow #20
Browse files Browse the repository at this point in the history
  • Loading branch information
sksamuel committed May 28, 2016
1 parent dd2c6be commit 2864eff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/kotlin/io/kotlintest/TestBase.kt
Expand Up @@ -13,7 +13,7 @@ abstract class TestBase : Matchers {
val e = try {
thunk()
null
} catch (e: Exception) {
} catch (e: Throwable) {
e
}

Expand Down
Expand Up @@ -21,6 +21,15 @@ class ExceptionMatchersTest : FreeSpec(), Matchers {
} catch (e: TestFailedException) {
}
}
"should test for throwables" {
try {
shouldThrow<Throwable> {
throw Throwable("bibble")
}
throw RuntimeException("If we get here its a bug")
} catch (e: TestFailedException) {
}
}
"return matched exception" {
val e = shouldThrow<IllegalAccessException> {
throw IllegalAccessException("bibble")
Expand Down

0 comments on commit 2864eff

Please sign in to comment.