# Not able to run unit tests on kotlin Multiplatform project

**URL:** <https://discuss.kotlinlang.org/t/not-able-to-run-unit-tests-on-kotlin-multiplatform-project/15779>\
**Category:** Multiplatform\
**Created:** [January 8, 2020, 3:49pm UTC](https://discuss.kotlinlang.org/t/not-able-to-run-unit-tests-on-kotlin-multiplatform-project/15779 "2020-01-08T15:49:08Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![nadeeshtv](https://avatars.discourse-cdn.com/v4/letter/n/90ced4/32.png) [@nadeeshtv](https://discuss.kotlinlang.org/u/nadeeshtv)\
**Post date:** [January 8, 2020, 3:49pm UTC](https://discuss.kotlinlang.org/t/not-able-to-run-unit-tests-on-kotlin-multiplatform-project/15779/1 "2020-01-08T15:49:08Z")

</div>

Hi all,

I am trying to create a kotlin Multiplatform library which can later convert into java and javascript using IDEA 2019.3, kotlin 1.3 .

I created a simple junit (4) test class and configured it as follows.

```auto
package sample;
import org.junit.Test;

public class Tests {
    @Test
    public void test1(){
        System.out.println("here");
    }

}

```

 ![Screenshot 2020-01-08 at 16.25.48](https://us1.discourse-cdn.com/flex019/uploads/kotlinlang/original/2X/6/6c9ece7e6eb2d1083afcf2e988820a4bb22bba56.png) But while running, it’s failing with

Process finished with exit code 1 Class not found: “sample.DummyTest”

I could not figure out what am I doing wrong. Please advice.

---

<div class="post-metadata">

**Author:** ![reitzig](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/reitzig/32/6970_2.png) [@reitzig](https://discuss.kotlinlang.org/u/reitzig)\
**Post date:** [January 9, 2020, 8:06am UTC](https://discuss.kotlinlang.org/t/not-able-to-run-unit-tests-on-kotlin-multiplatform-project/15779/2 "2020-01-09T08:06:38Z")

</div>

Do your tests run on the CLI through Gradle? If so, read on.

In addition to all the things found in the docs, I [discovered](https://github.com/reitzig/kotlin-introduction/blob/master/build.gradle.kts) that – even for JVM-only projects! – two dependencies are needed for IDEA to run the tests:

```kotlin
dependencies {
    implementation(kotlin("stdlib"))
    compileOnly("org.jetbrains", "annotations", "18.0.0")

    testImplementation(kotlin("test-junit5"))
    testRuntimeOnly("org.junit.jupiter", "junit-jupiter-engine", "5.5.2")

    // IDEA needs those:
    testCompileOnly("org.junit.jupiter", "junit-jupiter-api", "5.5.2")
    testCompileOnly("org.junit.jupiter", "junit-jupiter-params", "5.5.2")
}

```

That said, I _think_ I observed no tests being found; your problem _seems_ to be different. If so, my bad.

---

<div class="post-metadata">

**Author:** ![nadeeshtv](https://avatars.discourse-cdn.com/v4/letter/n/90ced4/32.png) [@nadeeshtv](https://discuss.kotlinlang.org/u/nadeeshtv)\
**Post date:** [January 9, 2020, 9:09am UTC](https://discuss.kotlinlang.org/t/not-able-to-run-unit-tests-on-kotlin-multiplatform-project/15779/3 "2020-01-09T09:09:17Z")

</div>

Thanks for the reply.  
I was trying to running it via IDEA itself. Right click on a test → then Run TestName…

---

<div class="post-metadata">

**Author:** ![Alexey.Belkov](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/alexey.belkov/32/5215_2.png) [@Alexey.Belkov](https://discuss.kotlinlang.org/u/Alexey.Belkov)\
**Post date:** [January 13, 2020, 11:55am UTC](https://discuss.kotlinlang.org/t/not-able-to-run-unit-tests-on-kotlin-multiplatform-project/15779/4 "2020-01-13T11:55:20Z")

</div>

Try to delete the created Junit run configuration and create a Gradle one (build and run tests using Gradle in “File | Settings | Build, Execution, Deployment | Build Tools | Gradle”). Does this help?

---

<div class="post-metadata">

**Author:** ![nadeeshtv](https://avatars.discourse-cdn.com/v4/letter/n/90ced4/32.png) [@nadeeshtv](https://discuss.kotlinlang.org/u/nadeeshtv)\
**Post date:** [January 13, 2020, 1:08pm UTC](https://discuss.kotlinlang.org/t/not-able-to-run-unit-tests-on-kotlin-multiplatform-project/15779/5 "2020-01-13T13:08:25Z")

</div>

Thanks for the reply. But it did not help.  
I deleted the created Junit run configuration and created a Gradle one.

Then I rightClick on jvm class and pressed run. But it failed with following exception.  
Just to note my tests are still annotated with junit.

```
FAILURE: Build failed with an exception.

* What went wrong:

Execution failed for task ':jvmTest'.

> No tests found for given includes: [mypackage.TestSample](filter.includeTestsMatching)

```

---

<div class="post-metadata">

**Author:** ![Alexey.Belkov](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/alexey.belkov/32/5215_2.png) [@Alexey.Belkov](https://discuss.kotlinlang.org/u/Alexey.Belkov)\
**Post date:** [January 13, 2020, 1:16pm UTC](https://discuss.kotlinlang.org/t/not-able-to-run-unit-tests-on-kotlin-multiplatform-project/15779/6 "2020-01-13T13:16:14Z")

</div>

If you have a multi-module MPP project, it’s probably this bug: [https://youtrack.jetbrains.com/issue/KT-35038](https://youtrack.jetbrains.com/issue/KT-35038). Please check the generated run configuration, it might be missing the correct Gradle project value as described in the issue. This is only a problem when running tests from gutter, ie. running `jvmTest` task from the Gradle tool window in IDEA should work fine.

---

<div class="post-metadata">

**Author:** ![nadeeshtv](https://avatars.discourse-cdn.com/v4/letter/n/90ced4/32.png) [@nadeeshtv](https://discuss.kotlinlang.org/u/nadeeshtv)\
**Post date:** [January 13, 2020, 1:49pm UTC](https://discuss.kotlinlang.org/t/not-able-to-run-unit-tests-on-kotlin-multiplatform-project/15779/7 "2020-01-13T13:49:30Z")

</div>

@Alexey.Belkov as far as I understood [https://youtrack.jetbrains.com/issue/KT-35038?\_ga=2.238248132.510151518.1578909478-1531068909.1578050245](https://youtrack.jetbrains.com/issue/KT-35038?_ga=2.238248132.510151518.1578909478-1531068909.1578050245) is talking about multi module multi platform project. Mine is single multiplatform project.  
In the javaTest, I wrote another Testfile( A.kt)with kotlin.test.Test annotation and that runs.  
But java test file (\*.java) is not running

---

<div class="post-metadata">

**Author:** ![Alexey.Belkov](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/alexey.belkov/32/5215_2.png) [@Alexey.Belkov](https://discuss.kotlinlang.org/u/Alexey.Belkov)\
**Post date:** [January 20, 2020, 9:37am UTC](https://discuss.kotlinlang.org/t/not-able-to-run-unit-tests-on-kotlin-multiplatform-project/15779/8 "2020-01-20T09:37:18Z")

</div>

Discussion continued in [Koltlin 1.3.61 - Multi platform project - Default Idea project - Not able to run java test in jvmTests](https://discuss.kotlinlang.org/t/koltlin-1-3-61-multi-platform-project-default-idea-project-not-able-to-run-java-test-in-jvmtests/15962)

---

<div class="post-metadata">

**Author:** ![oleg.vashenkov](https://avatars.discourse-cdn.com/v4/letter/o/a9adbd/32.png) [@oleg.vashenkov](https://discuss.kotlinlang.org/u/oleg.vashenkov)\
**Post date:** [May 17, 2020, 9:11pm UTC](https://discuss.kotlinlang.org/t/not-able-to-run-unit-tests-on-kotlin-multiplatform-project/15779/9 "2020-05-17T21:11:23Z")

</div>

My problem was in single path to kotlin and java tests. So kotlin tests are in **root/src/test/kotlin/package** and they are running fine with **gradle :cleanTest :test** and java tests must be in **root/src/test/java/package**. Otherwise neither **compileTestKotlin** nor **compileTestJava** will not find java tests to compile.
