Getting started
Writing your first test with KotlinTest is very straightforward. Firstly, the KotlinTest dependency will need to be added to your build. The easiest way to do this if you are using Gradle or Maven is to search Maven central for io.kotlintest
- just visit http://search.maven.org and grab the latest version. You will need to add this to your Gradle build using the following:
testCompile 'io.kotlintest:kotlintest:2.0.0'
Alternatively, for Maven, use the following code:
<dependency> <groupId>io.kotlintest</groupId> <artifactId>kotlintest</artifactId> <version>2.0.0</version> <scope>test</scope> </dependency>
Next, create the test source folder, usually src/test/kotlin
, if it doesn't exist already. We are going to write a unit test for the standard library String class. So create a file called StringTest.kt
. Inside this file, create a single class called StringTest...