Kotlin projects tests and structure


#1

Starting as if a person new to Kotlin, who is very much TDD oriented, I was looking for information about how to structure Kotlin projects, source code, unit tests, integration tests and such like. As far as I can tell there is no definite ionformation anywhere on how to approach writing Kotlin code from a TDD perspective. Well at least not as indexed by Google or more recent than 2012. Am I just moissing obvious material or is testing and Kotlin a bit of a hole re documentation and instruction to folk new to Kotlin?


#2

There's Spek (https://jetbrains.github.io/spek/). Also you can still use the same set of tools as when working with Java code (JUnit, TestNG, etc.)


#3

I've been mostly using the same convention that people use for Java.


#4

I possibly haven't tried Spek enough, but to date it doesn't really work for me compared to Spock.

@Unroll with where clause in spock for data-driven testing is a superb tool. Far better than DataProvider in TestNG and Parameterized and Theories in JUnit4.


#5

I find JUnit4 substandard compared to TestNG, and both substandard compared to Spock. Maybe I just have to stick to Spock.

IntelliJ IDEA appears not to have ready made dependencies for JUnit, TestNG or Spock; it is a pain having to manually create these dependencies in newly created projects. Maybe I have to stop using IntelliJ IDEA to create projects and always use a Gradle file so it can so all the dependency handling.