title: How to run kotlintest tests using the Gradle Kotlin DSL?
body: <p><strong>What do I want?</strong></p>
  
  <p>I want to run my tests using <a href="https://github.com/kotlintest/kotlintest" rel="noreferrer">kotlintest</a>, and I succeeded in running them from IntelliJ by clicking the icon next to the test class.
  I also have <a href="https://junit.org/junit5/" rel="noreferrer">JUnit 5</a> tests in my project.
  I am now starting to use the <a href="https://github.com/gradle/kotlin-dsl" rel="noreferrer">Gradle Kotlin DSL</a>, and I managed to run the Gradle task <code>check</code> which executed the JUnit 5 tasks.</p>
  
  <p><strong>What is the problem?</strong></p>
  
  <p>The kotlintest test is not run! It is not discovered by Gradle it seems, as a failing test lets the Gradle task succeed. So,</p>
  
  <blockquote>
    <p>How to run kotlintest tests using the Gradle Kotlin DSL while also using JUnit 5?</p>
  </blockquote>
  
  <p><strong>What did I try?</strong></p>
  
  <p><a href="https://stackoverflow.com/questions/45231313/how-can-i-run-kotlintest-tests-with-gradle/48459420?noredirect=1#comment86266799_48459420">How can I run kotlintest tests with gradle?</a> is essentially the old version of the question but already obsolete since using different technology: JUnit 4 and Gradle instead of the Gradle Kotlin DSL.
  All other question I could find are either for JUnit 4, or <a href="https://stackoverflow.com/a/49014534/4126843">JUnit 5 without kotlintest</a>.</p>
  
  <p><strong>Project setup</strong></p>
  
  <p>I am using Gradle 4.6.
  My test is</p>
  
  <pre><code>import io.kotlintest.matchers.exactly
  import io.kotlintest.matchers.shouldBe
  import io.kotlintest.specs.FunSpec
  
  class KotlinTest: FunSpec() {
  
      init {
          testCalculate()
      }
  
      /** This failing test will not fail the Gradle check. */
      fun testCalculate() = test("one plus one is two") {
          (1+1).toDouble() shouldBe exactly(42.0)
      }
  
  }
  </code></pre>
  
  <p>and my <code>build.gradle.kts</code> is</p>
  
  <pre><code>import org.gradle.api.plugins.ExtensionAware
  
  import org.junit.platform.gradle.plugin.FiltersExtension
  import org.junit.platform.gradle.plugin.EnginesExtension
  import org.junit.platform.gradle.plugin.JUnitPlatformExtension
  
  group = "mypackage"
  version = "0.0"
  
  // JUnit 5
  buildscript {
      repositories {
          mavenCentral()
          jcenter()
      }
      dependencies {
          classpath("org.junit.platform:junit-platform-gradle-plugin:1.1.0")
      }
  }
  
  apply {
      plugin("org.junit.platform.gradle.plugin")
  }
  
  // Kotlin configuration.
  plugins {
      application
      kotlin("jvm") version "1.2.30"
      java // Required by at least JUnit.
  }
  
  application {
      mainClassName = "mypackage.HelloWorld"
  }
  
  dependencies {
      compile(kotlin("stdlib"))
      // To "prevent strange errors".
      compile(kotlin("reflect"))
      // Kotlin reflection.
      compile(kotlin("test"))
      compile(kotlin("test-junit"))
  
      // JUnit 5
      testImplementation("org.junit.jupiter:junit-jupiter-api:5.1.0")
      testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.1.0")
      testRuntime("org.junit.platform:junit-platform-console:1.1.0")
  
      // Kotlintests are not run anyway when using JUnit 5 as well.
      testCompile("io.kotlintest:kotlintest:2.0.7")
  
  }
  
  repositories {
      jcenter()
  }
  </code></pre>
  
  <p>PS Complete project at <a href="https://github.com/PHPirates/kotlin-template-project" rel="noreferrer">GitHub</a>.</p>