Running Kotlin JUnit tests
Answered
I have a project with mixed Java and Kotlin classes, and I figured I would unit test my Kotlin classes using Kotlin.
I’ve created a new Kotlin test class, but can’t figure out how to actually run it. It doesn’t run when I run all the tests in the project. I can’t seem to create a new JUnit run configuration pointing to the class.
import org.junit.Assert
import org.junit.Test
class CsrfFilterTest
@Test
fun simpleTest() {
Assert.assertEquals(2, 1 + 1)
}
How can I get IDEA run this? Any pointers?
Please sign in to leave a comment.
My pom.xml has the following in it…
Hi Tobin,
I think that IDEA doesn't support top level test functions, please try to place it to the class (adding "{}").
Anna
Oh man, so stupid. I didn’t even think about that since there weren’t any compilation errors or anything thing.
Thanks!