Android Test running failed : No Test results

Hi i am trying to run the example instrumented test class in my project but everytime i run it i get this error:

Test running failed: no test results

Empty test suit

Here is my example intrumented test class

import org.junit.Assert.assertEquals

import org.junit.Test

import org.junit.runner.RunWith

/**

* Instrumented test, which will execute on an Android device.

*

* See [testing documentation](http://d.android.com/tools/testing).

*/

@RunWith(AndroidJUnit4::class)

class ExampleInstrumentedTest {

@Test

fun useAppContext() {

// Context of the app under test.

val appContext = androidx.test.platform.app.InstrumentationRegistry.getInstrumentation().context

assertEquals("com.app", appContext.packageName)

}

}

Here is my gradle build filefor tests:

android {

compileSdkVersion 28

defaultConfig {

applicationId "com.app"

minSdkVersion 21

targetSdkVersion 28

versionCode 1

versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

testInstrumentationRunnerArguments clearPackageData: 'true'

}

buildTypes {

release {

minifyEnabled false

proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

}

}

compileOptions {

sourceCompatibility JavaVersion.VERSION_1_8

targetCompatibility JavaVersion.VERSION_1_8

}

testOptions...

Read More »

By: StackOverFlow - 5 days ago

Related Posts