I have no idea how to test and I was following a tutorial.I am trying to run:
package name.company.sunshine.app.data;
import android.test.AndroidTestCase;
I am doing the course too and ended up with the same problem.
After an hour of tinkering I think I found the solution.
Don't try to run the the test cases from the whole package as they did in the video; you have to run it from a single class and choose the AndroidTest option. It does not work with the Gradle option.
See picture attached.
I was able to get past this problem after making two changes.
uncheck use in-process build
in Settings -> Build Tools -> Compiler
Source: https://code.google.com/p/android/issues/detail?id=172162
force Gradle to re-run all tasks by updating your run configurations. Add --rerun-tasks to the Script Parameters.
Source: https://www.bignerdranch.com/blog/triumph-android-studio-1-2-sneaks-in-full-testing-support/
just as Matt Accola sayd, if you already selected the gradle option and cant find that sub menu in his answer, u will need to go to run >> Edit Configuration... and then under the Gradle sub menu, delete the items (TestPractice & others if existed) and then re do the test by selecting the AnroidTest.
This solution is tested in android studio 1.5.1
If you have problem with tests in android studio because use in-process build disappeared, include the following:
<project-folder>
|-- .idea
|-- workspace.xml
Just add the following component at the very top, just inside the project tag:
<project version="4">
<component name="AndroidGradleBuildConfiguration">
<option name="USE_EXPERIMENTAL_FASTER_BUILD" value="false" />
</component>
...
</project>
When you run your test select the Android Test option.
The JUnit and Gradle options should not be used for this type of test.