Error "No tests found" when running Android instrumentation tests

I am a beginner to testing. I have created a simple test case for login activity in android studio. But I got an error and I could not solve it. Here is my test code. Help will be really appreciated.

package com.example.hassidiczaddic.testinglist;

import android.app.Application;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.test.ActivityInstrumentationTestCase2;
import android.test.ApplicationTestCase;
import android.test.suitebuilder.annotation.LargeTest;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.action.ViewActions.closeSoftKeyboard;
import static android.support.test.espresso.action.ViewActions.typeText;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;

@RunWith(AndroidJUnit4.class)
@LargeTest
public class ApplicationTest {

    public static final String STRING_TO_BE_TYPED = "Wolfmatrix";

    @Rule
    public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(MainActivity.class);

    @Test
    public void LoginActivity() {
        onView(withId(R.id.etFName))
                .perform(typeText(STRING_TO_BE_TYPED), closeSoftKeyboard());
        onView(withId(R.id.etLName))
                .perform(typeText(STRING_TO_BE_TYPED), closeSoftKeyboard());
        onView(withId(R.id.btnSubmit))
            .perform(click());
        onView(withId(R.id.tvView))
            .check(matches(withText(STRING_TO_BE_TYPED)));
    }

}

This is my error:

Running tests

$ adb shell am instrument -w -r   -e debug false -e class       
com.example.hassidiczaddic.testinglist.ApplicationTest
com.example.hassidiczaddic.testinglist.
test/android.test.InstrumentationTestRunner
Client not ready yet..Test running started
junit.framework.AssertionFailedError: No tests found in     
com.example.hassidiczaddic.testinglist.ApplicationTest
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:190)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:175)
at    
android.test.InstrumentationTestRunner.onStart
(InstrumentationTestRunner.java:555)
at android.app.Instrumentation$InstrumentationThread.run
(Instrumentation.java:1619)
Tests ran to completion.

Here is my gradle file:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "com.example.hassidiczaddic.testinglist"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
        }
    }

    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        testCompile 'junit:junit:4.12'
        compile 'com.android.support:appcompat-v7:23.0.1'
        // App dependencies
        compile 'com.android.support:support-annotations:23.0.1'
        compile 'com.google.guava:guava:18.0'
        androidTestCompile 'com.android.support:support-annotations:23.0.1'
        androidTestCompile 'com.android.support.test:runner:0.4.1'
        androidTestCompile 'com.android.support.test:rules:0.4.1'
        androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
    }
}

You have forgotten to set AndroidJUnitRunner as the default test instrumentation runner.

https://developer.android.com/topic/libraries/testing-support-library/index.html

To set AndroidJUnitRunner as the default test instrumentation runner in your Gradle project, specify this dependency in your build.gradle file:

android {
    defaultConfig {
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
}

Update

with androidx things have changed a little, check https://developer.android.com/training/testing/set-up-project

Error, error, mistake, and blunder mean an act or statement that is not right or true or proper. error is used for failure to follow a model correctly. There was an error in the addition. mistake is used when someone misunderstands something or does not intend to do wrong. Delusions, errors and likes are like huge, gaudy vessels, the rafters of which are rotten and worm-eaten, and those who embark in them are fated to be shipwrecked —Buddha Errors, like straws, upon the surface flow; he who would search for pearls must dive below —John Dryden


If you are targeting SDK Version 28, you'll be using the re-packaged androidx classes from the support library, so AndroidJUnitRunner is configured like so...

android {
    defaultConfig {
        testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
    }
}

Error, 1.1mass noun The state or condition of being wrong in conduct or judgement. ' goods dispatched to your branch in error'. More example sentences. Error, in applied mathematics, the difference between a true value and an estimate, or approximation, of that value. In statistics, a common example is the difference between the mean of an entire population and the mean of a sample drawn from that population.


check build.gradle

replace testInstrumentationRunner "androidx.test.runner.AndroidJUnit4"

android {
    defaultConfig {
        testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
    }
}

Look for app/src/androidTest/AndroidManifest.xml

change android:name to androidx.multidex.MultiDexApplication

<application
        android:allowBackup="true"
        android:label="Components Tests App"
        android:supportsRtl="true"
        android:name="android.support.multidex.MultiDexApplication">

To

<application
            android:allowBackup="true"
            android:label="Components Tests App"
            android:supportsRtl="true"
            android:name="androidx.multidex.MultiDexApplication">

More suggestions: No tests found when running instrumented tests with AndroidX

Error, Error objects are thrown when runtime errors occur. The Error object can also be used as a base object for user-defined exceptions. See below� The judge was in error when she allowed the evidence to be admitted. 2 : in a way that is not correct My earlier statement was made in error. The evidence was admitted in error. Learn More about in error


ERROR, NounEdit. error (countable and uncountable, plural errors). (uncountable) The state, quality, or condition of being wrong. quotations ▽. 1913, The Inland printer: . Err stems from the Latin word errare, meaning “to stray, wander,” and it retained that meaning when it first entered English. We find the same Latin ancestor at the root of the words error, erratic, and erroneous. Examples of err in a Sentence I may have erred in my calculations.


Error, Another word for error. Find more ways to say error, along with related words, antonyms and example phrases at Thesaurus.com, the world's most trusted free� icon in the notification area, and then select Troubleshoot problems. Follow the steps in the wizard to diagnose and resolve your network problems. Run Windows Update again.


error, Video shows what error means. The state, quality, or condition of being wrong.. A mistake; an Duration: 0:52 Posted: Apr 12, 2015 The purpose of a percent error calculation is to gauge how close a measured value is to a true value. Percent error (percentage error) is the difference between an experimental and theoretical value, divided by the theoretical value, multiplied by 100 to give a percent. In some fields, percent error is always expressed as a positive number.