0

I am trying to run JUnit 5 tests on android studio bumblebee. I want to run these using JUnitTest runner instead of gradle test runner. but android studio is picking gradle as test runner. And tests are not running with error Test events were not received

FAILURE: Build failed with an exception. What went wrong: Execution failed for task ':app:testDebugUnitTest'. No tests found for given includes: com.example.sampleproject.ExampleTest

I looked at many answers on internet but no luck.

build.gradle (Project)

plugins {
    id 'com.android.application' version '7.1.3' apply false
    id 'com.android.library' version '7.1.3' apply false
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

tasks.withType(Test) {
    useJUnitPlatform()
}

build.gradle (app)


plugins {
    id 'com.android.application'
}

android {
    compileSdk 32

    defaultConfig {
        applicationId "com.example.sampleproject"
        minSdk 21
        targetSdk 32
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {

    implementation 'androidx.appcompat:appcompat:1.4.1'
    implementation 'com.google.android.material:material:1.5.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
    testImplementation "org.junit.jupiter:junit-jupiter:5.8.2"
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

I am using gradle 7.4.2. I also tried to look for an option run test using (gradle/ intellij) in

Settings -> Build, Execution, Deployment -> Build Tools -> gradle

but it seems I have less number of options there.

gradle options

Note : Junit 4 tests are running using gradle runner.

James Z
  • 12,209
  • 10
  • 24
  • 44

0 Answers0