Skip to content

Instantly share code, notes, and snippets.

@erikhuizinga
Last active January 2, 2020 16:18
Show Gist options
  • Save erikhuizinga/ee19aeaf06140b49e9e4f6ea7213ccad to your computer and use it in GitHub Desktop.
Save erikhuizinga/ee19aeaf06140b49e9e4f6ea7213ccad to your computer and use it in GitHub Desktop.
package com.example
import org.junit.Assert.assertEquals
import org.junit.Assert.assertThrows
import org.junit.Test
import org.junit.function.ThrowingRunnable
/**
* JUnit 4.13 test
*/
class `JUnit 4 dot 13 Test` {
@Test
fun `use assertThrows`() {
val message = "Hello, World!"
val actual = assertThrows(
RuntimeException::class.java,
ThrowingRunnable { throw RuntimeException(message) }
)
assertEquals(message, actual.message)
}
}
@erikhuizinga
Copy link
Author

Link back to corresponding Android Studio JUnit 4.13 issue on the Google Issue Tracker: https://issuetracker.google.com/issues/147066405.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment