I'm beginning to use tests in my Kotlin projects, ...
# test
b
I'm beginning to use tests in my Kotlin projects, is there any recommended framework (really basic needs for now)
d
Maybe #mockk and #kotlintest ?
#spek is more rigid in form but has an IDE plugin that is more developed, but releases take more time..
And for more advanced assertions there's #atrium and #strikt and Kluent
b
junit will give you everything you need.
d
True, but I supposed he's looking for Kotlin based solutions. Junit doesn't mock, and doesn't have built-in coroutine support (so you jave to runBlocking every test).
c
#minutest is also pretty nice
b
No net necessarily kotlin-based (even if I usually try to favor them), I started with junit because that's the one that had the most examples online. seems to work decently for now.
s
I'd contend that KotlinTest's assertions are the most advanced/complete out there
d
By advanced, I meant atrium has reporting and different language support and I think is working on multiplatform, strikt is more close to assertj in syntax, but doesn't have as many assertions, some are more comfortable with function chaining assertj style. At first I didn't jump into KotlinTest because the assertions were part of the testing framework, and I didn't like infix style and another few points (I still think they could be in a seperate module for those that prefer other assertion frameworks...), now I'm starting to get used to it... @sam
b
I'm really only using assert[True/False] assertEqual and assertThrows… Nothing fancy, in some cases I use the setupup/toredown mechanism too.
s
@dave08 thanks for the feedback. You can use infix or not, eg
"a".shouldBeEmpty()
or
"a" should beEmpty()
. I prefer the former as the IDE can discover it. Different languages is a nice idea, Atrium is good in that respect. In KotlinTest the assertions are available "outside" of kotlintest itself, you can use KotlinTest assertions with Spek for example. But KotlinTest the "test framework" brings them in as they're a) the best 😉 and b) very lightweight so why not. I think KotlinTest has the most assertions outside of assertJ as well.
I've created this issue for discussion https://github.com/kotlintest/kotlintest/issues/681 @dave08 @LeoColman
c
in strikt it is very easy to add new assertions.