views:

467

answers:

3

I would like to automatically generate unit testing report in html format for Android application on Hudson continuous integration server.

Therefore, I try to run test cases first and gather test result files in xml format. Then, I use JUnitReport Task to transform the XML result files into HTML format.

I run test cases through Android instrumentation framework. However, it only provides verbose output information rather than the standard JUnit XML format. I have no idea how to generate HTML unit test report without JUnit XML result files.

If I run test cases using Eclipse, it can export results in XML files with time consumed information per test case. Those XML files can be transformed into HTML by JUnitReport Task correctly. As a result, it seems that it is possible to collect the test result with time consumed information.

Is there any way to get the standard JUnit XML result file automatically after running test cases on Android instrumentation framework?

+1  A: 

I don't think it is possible, so you need to create a utility that converts the Android test runner output into JUnit-format XML files.

However, you won't be able to get the time-per-test value, as the Android test runner doesn't seem to output that information.

Christopher
Thanks for your answer. I added a paragraph as response.
papalagi
Interesting; I've seen the Android test runner output and looked at the source code previously but didn't see anything about outputting times. So I wonder how it works in Eclipse. I guess a look at the ADT plugin is in order...
Christopher
I looked into the runner's source and found nothing, too. But I found that there are two test runner output parsers written in Java and Python in path "/development/testrunner" and "/development/tools/ddms" respectively. They help a lot to parse the test runner's verbose output. Surprisingly, both of them use "performance" as key to fetch time information. Furthermore, test cases for output parser in path "/development/testrunner/tests" contain performance test data. So I think there should be a way to turn on performance output.
papalagi
Ah ok, though I'm not quite sure what "performance" refers to. Is that not something where you have to instrument your code? Anyway, I looked at the Android Eclipse plugin the other day, that *does* have code where it calculates the time for each test run, as it's required by the Eclipse JUnit infrastructure. The Eclipse plugin test runner sends 'test started' and 'test ended' events, so it's trivial to calculate the execution time as it happens.
Christopher
Add annotation @android.test.TimedTest for test cases will make test runner output time information.
papalagi
That API isn't yet public. Why can't they just output that information in the first place anyway? :(
Christopher
A: 

I have a stupid question .. has anyone tried running the ant task junit with the android.jar as the supplied junit jar?

I mean the runners ar eon the device/emulator and unit stubs via the android.jar right?

Fred Grott
I can't see any 'junit' target in the Android ant scripts or any part of the SDK. Where did you see this, and does it output test results in the JUnit XML format?
Christopher
+1  A: 

I just saw that Dan Watling of DroidDudes work a tool named Athena which seems to be similar as what you want.

You can find it there: http://droiddudes.com/

ol_v_er