Using Kotlin with JUnit4


#1

Hi there.  :)

I’m just getting into the Kotlin language (just the simpler stuff) and I thought I’d start with converting a few unit tests. I’m using some of the JUnit4 annotations and I seem to have run into one a small problem:

@RunWith(SpringJUnit4ClassRunner.class)

is okay in Java, but I’m not sure how to convert that in Kotlin since I don’t seem to have access to the static class.

Is it possible to do this in Kotlin?


#2

Hang on...

I think I have it.

This might work:

[RunWith(javaClass<SpringJUnit4ClassRunner>())]

Yep! That did it.