android-studio-unit-test-plugin icon indicating copy to clipboard operation
android-studio-unit-test-plugin copied to clipboard

Running tests from IDE does not recompile test classes

Open gbegen opened this issue 10 years ago • 6 comments

Android Studio: 1.0.1 android-unit-test: 2.1.1 android-studio-unit-test-plugin: 1.4.0

It appears that recent changes to this plugin have attempted to add a make task before running the unit tests that should run with a goal of testDebugClasses, but it only seems to be running with a goal of assembleDebug anyway.

Therefore, after a project cleaning, I get the ClassNotFound error until I build from the command line.

Also, if I make changes to the tests, they don't get recompiled when I run the tests from the IDE.

gbegen avatar Jan 02 '15 20:01 gbegen

Noticing this as well. If I have some time I'll dig into the plugin to see if I can come up with a fix.

coreydowning avatar Jan 08 '15 16:01 coreydowning

Is there a workaround until this is fixed?

clemp6r avatar Jan 30 '15 11:01 clemp6r

You can try some of the workarounds from before the latest update. One of:

  1. Add tasks.findByName("assembleDebug").dependsOn("testDebugClasses") to your build.gradle to force the test classes to be compiled whenever your project is compiled.
  2. Go to Edit Configurations and add a new gradle configuration that runs the task testClasses. Then in your junit configuration, below Before launch, click + -> Run Another Configuration and add the gradle configuration you just created.

evant avatar Jan 30 '15 16:01 evant

Alternative 1 ends in an error due to circular dependencies of tasks.

The second one works, but needs to be done for each test you run.... Any timeline on getting this fixed? Any way I can help?

jsotuyod avatar Feb 06 '15 01:02 jsotuyod

I'm not quite experiencing this issue (it fails the first time after a clean but then works correctly after that). So I'd need more info about your project setup. Honestly though, I'm not really invested on working on this anymore since google is releasing a proper solution.

evant avatar Feb 06 '15 03:02 evant

Official solution: that's good news!

clemp6r avatar Feb 06 '15 10:02 clemp6r