11

My android app is multi module project:

include (android-app/kotlin-android)':application', (pure kotlin)':presentation', (pure kotlin)':domain', (android-library/kotin-android)':dataproviders'

Modules :application and :dataproviders working fine with Spock, test running and completing without problems. But :presentation and :domain which are pure kotlin modules have problem with spock framework. There are my simple examples:

MostPopularPresenterTest.groovy

class MostPopularPresenterTest extends Specification {

    def "exampleTest"(){
        when:
        int i = 1
        then:
        i == 1
    }
}

This test end with error:

Class not found: "pl.hypeapp.presentation.mostpopular.MostPopularPresenterTest"Empty test suite.

But, test written in Java/Junit4 passing well and did not throw any error:

MostPopularPresenterTest2.java

public class MostPopularPresenterTest2 {

    @Test
    public void test(){
        assertEquals(1, 1);
    }
}

I'm using Android Studio 3.0 Canary 5 You can look at my build.gradle files at github:

build.gradle

dependencies.gradle

application.build.gradle

presentation.build.gradle

Can someone help me with my problem?

EDIT: while ran /.gradlew test test are running.

Hype
  • 1,039
  • 1
  • 10
  • 27
  • Try to run the tests on the whole package rather than only one file. That solved this problem for me once. – dipdipdip Jul 11 '17 at 14:48
  • @dipdipdip Do you mean "Run all tests" (CTRL + SHIFT + F10) or changing test kind in Edit Configurations? Both option throws error about empty test, but if I delete spock test all tests(java classes) they running well. – Hype Jul 11 '17 at 14:54
  • Looking at your config one difference is that the working projects us groovy-/kotlin-android plugins while the failing projects use the plain plugin variants. Maybe the android plugins do something that is missing in the plain ones? Furthermore, does your edit comment mean, that the spock tests work when run with gradle but not when run within intellij? – Leonard Brünings Jul 11 '17 at 19:26
  • @LeonardBrünings I think plugins are fine. Exactly, spock test works from command line using gradlew test. Only with InteliJ Android Studio is something wrong. – Hype Jul 11 '17 at 20:07
  • 1
    exact same problem here... Looks like something's wrong with AS – mbonnin Sep 10 '17 at 22:13
  • same here... multiple modules and the pure kotlin modules can't run tests ... – Poweranimal Sep 13 '17 at 20:17
  • Has anyone found a solution to this or reported a bug? – user1809913 Oct 26 '17 at 23:04
  • I have a weird situation, with two test classes, one in Java and one in Kotlin (but of course, I'd rather write my tests with the latter). Running `./gradlew test` generates a report only containing the Java class test result, not the Kotlin one. Similarly, Android Studio runs the Java class well, but not the Kotlin one, with the same `Empty test suite` error message. Any help would be appreciated on this topic. – Stéphane Péchard Nov 17 '17 at 08:10
  • https://issuetracker.google.com/issues/38454212 – Henry Mar 12 '18 at 15:04

1 Answers1

2

Open context menu on parent package of your test and select item "Run tests in ..."