Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline lambdas passed to assertDoesNotThrows to support suspending functions #2684

Original file line number Diff line number Diff line change
Expand Up @@ -96,32 +96,26 @@ class KotlinAssertionsTests {
dynamicContainer("fails when an exception is thrown", Stream.of(
dynamicTest("for no arguments variant") {
val exception = assertThrows<AssertionError> {
assertDoesNotThrow {
assertDoesNotThrow<Unit> {
williamboman marked this conversation as resolved.
Show resolved Hide resolved
fail("fail")
@Suppress("UNREACHABLE_CODE")
""
}
}
assertMessageEquals(exception,
"Unexpected exception thrown: org.opentest4j.AssertionFailedError: fail")
},
dynamicTest("for message variant") {
val exception = assertThrows<AssertionError> {
assertDoesNotThrow("Does not throw") {
assertDoesNotThrow<Unit>("Does not throw") {
fail("fail")
@Suppress("UNREACHABLE_CODE")
""
}
}
assertMessageEquals(exception,
"Does not throw ==> Unexpected exception thrown: org.opentest4j.AssertionFailedError: fail")
},
dynamicTest("for message supplier variant") {
val exception = assertThrows<AssertionError> {
assertDoesNotThrow({ "Does not throw" }) {
assertDoesNotThrow<Unit>({ "Does not throw" }) {
fail("fail")
@Suppress("UNREACHABLE_CODE")
""
}
}
assertMessageEquals(exception,
Expand Down