Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
src
README.md
build.gradle

README.md

Running Kotlin Tests With Gradle

This example demonstrates how we can create a Gradle project that can compile and run both unit and integration tests which use Kotlin and JUnit 5.

The requirements of our example are:

  • All code (application and tests) must use Kotlin.
  • Unit and integration tests must have separate source and resource directories.
  • It must be possible to run only unit or integration tests.
  • It must be possible to run both unit and integration tests.

Note: This example isn't compatible with Gradle 6.0. I am currently debugging this problem.

Running Unit Tests

We can run our unit tests by using the Maven Surefire plugin. When we want to run our unit tests, we have to run the following command at command prompt:

gradle clean test

Running Integration Tests

We can run our integration tests by using the Maven Failsafe plugin. When we want to run our integration tests, we have to run the following command at command prompt:

gradle clean integrationTest

Running All Tests

When we want to run both unit and integration tests, we have to run the following command at command prompt:

gradle clean test IntegrationTest       

or we can use the command:

gradle clean build
You can’t perform that action at this time.