Test events were not received – Android Studio-ThrowExceptions

Exception or error:

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;

public class TestPractice extends AndroidTestCase {
       This gets run before every test.
    protected void setUp() throws Exception {

    public void testThatDemonstratesAssertions() throws Throwable {
        int a = 5;
        int b = 3;
        int c = 5;
        int d = 10;

        assertEquals("X should be equal", a, c);
        assertTrue("Y should be true", d > a);
        assertFalse("Z should be false", a == b);

        if (b > d) {
            fail("XX should never happen");

    protected void tearDown() throws Exception {

but I get somewhere in the bottom left corner, in the console Test events were not received. What am I doing wrong ? Should I run something else ?

How to solve:

When you run your test select the Android Test option.

Screen Shot

The JUnit and Gradle options should not be used for this type of test.


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/


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:

|-- .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" />



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.

Leave a Reply

Your email address will not be published. Required fields are marked *