Android Studio 3 does not run tests in Spock

I upgraded Android Studio to version 3, and since then all my test-spocks, when in the Java module , do not start when trying to run them from the application (right-click on groovy folder โ†’ Run 'Tests in groovy'). I get:

Class not found: "package.name.classname" An empty test suite. "

Same thing if I try to run one test.

If I run a test task from the gradle panel, I get the following: error. Reason: unknown.


On the other hand:

  • Any spock tests in android modules work fine.
  • All my Java tests in all my modules work fine.
  • All my tests (spock and java) work fine when running them from outside AS using gradle (gradlew cleanup test).

My setup:


A few things I tried after searching both Google and here:

  • change android gradle plugin back in version 2.3.3 and gradle to version 3.3
  • trying to copy all groovy classes to build / classes / java / test
+5
source share
1 answer

So, this is more of a workaround than a real solution, but it should give you a debugger back, which is probably 90% of the cost:

You can run a test suite, for example:

./gradlew <module>:test --debug-jvm 

And the jvm running your tests will be paused until the debugger arrives.

From Android Studio, pick up the action selection element by pressing ctrl + shift + a (anyway, on linux, check the equivalent of your OS) and select:

Bind to local process ...

As soon as the Android Studio application starts running the tests, it starts working.

The --debug-jvm flag can be used with --tests to debug a single test:

 ./gradlew <module>:test --tests fully.qualified.test.Test --debug-jvm 
+2
source

Source: https://habr.com/ru/post/1272918/


All Articles