Question: In Java, the programmer can specify expected exceptions for JUnit test cases like this:

```
@Test(expected = ArithmeticException.class)
public void omg()
{
    int blackHole = 1 / 0;
}

```

How would I do this in Kotlin? I have tried two syntax variations, but none of them worked:

```
import org.junit.Test

// ...

@Test(expected = ArithmeticException) fun omg()
    Please specify constructor invocation;
    classifier 'ArithmeticException' does not have a companion object

@Test(expected = ArithmeticException.class) fun omg()
                            name expected ^
                                            ^ expected ')'

```

Answer: 
[Kotlin has its own test helper package](https://github.com/JetBrains/kotlin/tree/master/libraries/kotlin.test) that can help to do this kind of unittest.

Your test can be very expressive by use `assertFailWith`:

```
@Test
fun test_arithmethic() {
    assertFailsWith<ArithmeticException> {
        omg()
    }
}

```
You can also use generics with kotlin.test package:

```
import kotlin.test.assertFailsWith 

@Test
fun testFunction() {
    assertFailsWith<MyException> {
         // The code that will throw MyException
    }
}

```