2022-10-20

Parse protobuf response from adb shell am instrument, to json or xml

I want to get test results in some structure that I can work with the command adb shell am instrument. From adb shell am help menu:

instrument
   -m: Write output as protobuf to stdout (machine readable)

and the response looks something like this:

?"?
7
class.com.example.myfirstapp.ExampleInstrumentedTest


current

idAndroidJUnitRunner


numtests
:
stream0
com.example.myfirstapp.ExampleInstrumentedTest:

testtest1
??C"?
7
class.com.example.myfirstapp.ExampleInstrumentedTest


current

idAndroidJUnitRunner


numtests


stream.

testtest1*??C--------- beginning of main

Is there a way to parse this to xml or json?


UPDATE

My goal was to receive the Android test results from the execution. For that I found an open source tool - Spoon - that does it (among other things) https://github.com/square/spoon

After executing the test with spoon, the result XML file is in spoon-output/junit-reports directory.



No comments:

Post a Comment