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

tim

03/11/2020, 12:15 PM
is there an easy way to order kotlin test like junits Order()?
a

Antoine Gagnon

03/12/2020, 4:13 PM
Are you unable to use the annotation @Order(1) for instance?
You would also need to add this annotation above your test class:
@TestMethodOrder(OrderAnnotation.class)
t

tim

03/12/2020, 4:17 PM
That's what I'm using currently but it requires the junit jupiter package... I was curious if there was anything inside kotlin.test.* that accomplished the same without the additional package
a

Antoine Gagnon

03/12/2020, 4:35 PM
You’re not using any JUnit package?
t

tim

03/12/2020, 4:58 PM
This kotlin guide (https://kotlinlang.org/docs/reference/using-gradle.html) says to add these test dependencies:
Copy code
testImplementation(kotlin("test"))
testImplementation(kotlin("test-junit"))
but as far as i can tell TestMethodOrder isn't available in those packages and you need to add:
Copy code
testImplementation("org.junit.jupiter:junit-jupiter:5.6.0")
So let me rephrase my question ... is there an easy way to order tests using only Kotlin's recommended testImplementation packages, or do you have to add the jupiter package to have test ordering? If you have to add the jupiter package ... whats the point of adding the kotlin test package in the first instance and why not simply recommend the jupiter pacakge?
sorry i made that way more confusing than it needed to be 😆
a

Antoine Gagnon

03/12/2020, 5:04 PM
Pretty sure it's just that the test package only has JUnit4 and the recommendations I'm making are for JUnit 5! There is a way to do it for JUnit 4 that's very smiliar (I just don't know it haha)
t

tim

03/12/2020, 5:24 PM
Ahh k
I'll stick with 5!
Thanks for your help
23 Views