I want to write a unit test for my Kotlin code and use junit/hamcrest matchers, I want to use the is
method, but it is a reserved word in Kotlin.
How can I get the following to compile?
class testExample{
@Test fun example(){
assertThat(1, is(equalTo(1))
}
}
Currently my IDE, InteliJ is highlighting that as a compilation error, saying it is expecting a )
after is
?
You can alias is
to Is
(for example), when you import, using the as
keyword.
E.g:
import org.hamcrest.CoreMatchers.`is` as Is