Home » Android » android – Cant run instrumentation with InstrumentationRunListener-Exceptionshub

android – Cant run instrumentation with InstrumentationRunListener-Exceptionshub

Posted by: admin February 26, 2020 Leave a comment


I am trying to run android instrumentation tests with a custom run listener

Here is my listener
this class resides in the folder app/src/androidTest/java/com/app/myapp

class AnnotationTestListener : InstrumentationRunListener() {
    override fun testStarted(description: Description) {
        val bundle = Bundle()
        instrumentation.sendStatus(InstrumentationResultPrinter.REPORT_VALUE_RESULT_START, bundle)


then I am trying to invoke the instrumentation listener the following way

adb shell am instrument -w -r -e log true -e listener com.app.myapp.AnnotationTestListener com.app.myapp.test/androidx.test.runner.AndroidJUnitRunner | tee -a listeners/test.txt

but the result is

INSTRUMENTATION_RESULT: shortMsg=Process crashed.

adb shell pm list instrumentation yields

instrumentation:androidx.test.orchestrator/.AndroidTestOrchestrator (target=androidx.test.orchestrator)
instrumentation:com.app.myapp.test/androidx.test.runner.AndroidJUnitRunner (target=com.app.myapp)

How to fix the problem?

How to&Answers: