i use assertj. among others it has functions assertThat(int)
and assertThat(Object)
. i would like to add my own function
fun <T> assertThat(flux: Flux<T>) = assertThat(flux.toStream())
but then it seems like i can't easily use it. when i declare the function outside of testing class MyTest
, function call in tests binds to assertThat(Object)
instead of assertThat(Flux)
:
import org.assertj.core.api.Assertions.assertThat
//<----------- if declared here, doesn't work
class MyTest {
//<----------- if declared here, all is ok
@Test fun test() {
assertThat(Flux.just(1)).containsExactly(1)
}
}
what should i do to be able to use my function?
You can define it in an extra file and import it explicitely. I think it even helps to add the import when it's defined in your file, but IDE shows this import as unused.
Suggestion would be: define extension in your/package/testutils.kt
and import it then:
import your.package.assertThat