allure-framework / allure-kotlin

Allure integrations for test frameworks targeting Kotlin and Java with 1.6 source compatibility.
Apache License 2.0
57 stars 21 forks source link

0 tests found in test module #78

Closed mandrachek closed 1 year ago

mandrachek commented 1 year ago

I'm submitting a ...

What is the current behavior?

Using a test module, and replacing testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" with testInstrumentationRunner "io.qameta.allure.android.runners.AllureAndroidJUnitRunner" results in 0 tests found.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem

I have a small application, with a single activity in the typical :app module. I've created a test module as mentioned above, and have set the targetProjectPath to :app. In my test/src/main/java, I have a single test class and single test method. The same for debug/src/main/java and release/src/main/java (except different class names and sub-packages for debug and release specific tests. The AndroidJUnitRunner successfully finds 2 tests (main and debug) when I run connectedDebugAndroidTest.

What is the expected behavior?

AllureAndroidJUnitRunner should find and execute the same tests as AndroidJunitRunner

What is the motivation / use case for changing the behavior?

To be able to use allure.

Please tell us about your environment:

| Test framework | junit@4.13.2| | Allure integration | allure-kotlin-android@2.4.0 |

Other information

My test module's build.gradle looks like this:

plugins {
    id 'com.android.test'
    id 'org.jetbrains.kotlin.android'
}

android {
    namespace 'com.myapp.test'
    compileSdk 33

    defaultConfig {
        minSdk 28
        targetSdk 33
        testApplicationId 'com.myapp.test'
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        testInstrumentationRunnerArguments clearPackageData: 'true'

        consumerProguardFiles "consumer-rules.pro"

        signingConfigs {
            release {
               // redacted
            }
            debug {
               // redacted
            }
        }
    }

    buildTypes {
        release {
            // this is for the test apk, so it's ok to make this debuggable
            debuggable = true
            signingConfig signingConfigs.release
        }
        debug {
            debuggable = true
            signingConfig signingConfigs.debug
            applicationIdSuffix = ".debug"
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

    targetProjectPath ':app'

    testOptions {
        animationsDisabled = true
        execution 'ANDROIDX_TEST_ORCHESTRATOR'
    }

    installation {
        installOptions '-g', '-r'
    }
}

dependencies {
    implementation("androidx.activity:activity-ktx:1.6.1")

    implementation "androidx.test:core:1.5.0"
    implementation "androidx.test:core-ktx:1.5.0"
    implementation "androidx.test.services:test-services:1.4.2"

    implementation ("androidx.test.espresso:espresso-accessibility:3.5.1") {
        exclude module: "protobuf-lite"
    }
    implementation ("androidx.test.espresso:espresso-contrib:3.5.1") {
        exclude module: "protobuf-lite"
    }

    implementation "androidx.test.espresso:espresso-core:3.5.1"
    implementation "androidx.test.espresso:espresso-idling-resource:3.5.1"
    implementation "androidx.test.espresso:espresso-intents:3.5.1"
    implementation "androidx.test.espresso:espresso-remote:3.5.1"
    implementation "androidx.test.espresso:espresso-web:3.5.1"
    implementation "androidx.test.espresso.idling:idling-concurrent:3.5.1"
    implementation "androidx.test.espresso.idling:idling-net:3.5.1"
    implementation "androidx.test.ext:truth:1.5.0"
    implementation "androidx.test.ext:junit-ktx:1.1.5"
    implementation "androidx.test:rules:1.5.0"
    implementation 'androidx.test.uiautomator:uiautomator:2.2.0'

    implementation "io.qameta.allure:allure-kotlin-model:2.4.0"
    implementation "io.qameta.allure:allure-kotlin-commons:2.4.0"
    implementation "io.qameta.allure:allure-kotlin-junit4:2.4.0"
    implementation "io.qameta.allure:allure-kotlin-android:2.4.0"

    androidTestUtil 'androidx.test:orchestrator:1.4.2'

    implementation 'junit:junit:4.13.2'
    implementation 'androidx.test.ext:junit:1.1.5'
}
mandrachek commented 1 year ago

Adding:

<instrumentation
    android:name="io.qameta.allure.android.runners.AllureAndroidJUnitRunner"
    android:targetPackage="APP_PACKAGE_HERE"/>

To the AndroidManifest.xml seems to have solved this problem.