https://kotlinlang.org logo
#test
Title
# test
b

bjonnh

01/21/2019, 2:44 AM
I'm beginning to use tests in my Kotlin projects, is there any recommended framework (really basic needs for now)
d

dave08

01/21/2019, 4:00 AM
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

Ben

01/21/2019, 9:09 PM
junit will give you everything you need.
d

dave08

01/22/2019, 3:31 AM
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

christophsturm

01/25/2019, 10:12 AM
#minutest is also pretty nice
b

bjonnh

01/26/2019, 3:31 AM
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

sam

02/16/2019, 8:30 PM
I'd contend that KotlinTest's assertions are the most advanced/complete out there
d

dave08

02/16/2019, 8:50 PM
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

bjonnh

02/17/2019, 7:19 PM
I'm really only using assert[True/False] assertEqual and assertThrows… Nothing fancy, in some cases I use the setupup/toredown mechanism too.
s

sam

02/18/2019, 12:33 PM
@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

christophsturm

02/18/2019, 3:12 PM
in strikt it is very easy to add new assertions.
3 Views