Skip to content

Android Test Orchestrator throwing ClassNotFoundException Invalid name for parameterized tests #975

@adil-hussain-84

Description

@adil-hussain-84

Description

In an instrumentation test class which is to run as a Parameterized test, if any of the parameters is an enum value and {0}, {1} etc is used in the Parameterized.Parameters.name pattern, then Android Test Orchestrator fails to run the parameterized test and throws a ClassNotFoundException with a message of "Invalid name".

Steps to Reproduce

  1. Define a parameterized test class in the androidTest folder of an Android project.
  2. Ensure that one of the parameters is an enum value.
  3. Set the Parameterized.Parameters.name value (which is passed into the Parameterized.Parameters annotation) to "{0}".
  4. Add testOptions.execution 'ANDROIDX_TEST_ORCHESTRATOR' to the Android project's build.gradle file so that the instrumentation tests run with Android Test Orchestrator.
  5. Run the test class.

Expected Results

The parameterized tests runs fine.

Actual Results

The parameterized tests throw ClassNotFoundException with a message of "Invalid name".

AndroidX Test and Android OS Versions

androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestUtil 'androidx.test:orchestrator:1.3.0'

Attempted with an Android 5.1, Android 10.0 and Android 11.0 emulator. All exhibit the same behaviour.

Link to a public git repo demonstrating the problem:

See the BadParameterizedTest.kt, GoodParameterizedTest.kt and build.gradle files in particular.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions