Sorry for the late response - see inline:

On Wed, Dec 16, 2009 at 5:33 AM, Praetor <[email protected]> wrote:

> Hi all,
> I've a question about generating XML reports after unit tests. I want
> to move build process to Hudson build server. It has plugins, which
> can read JUnit and Emma reports in XML file format, parse them and
> view in nice looking way.  My first thought was to create ant
> buildifle in which I would compile sources, add instrumentation and
> run Junit tests with instrumentated code, and generate report (using
> Emma and Junit tasks). It works fine but only when classes which don't
> use Android classses (e.g. Log.d("TAG","Log message")) were tested.
> I've found that this is because Android classes are available only in
> actual runtime (real device, emulator) - trying to test not on
> emulator caused runtime exception: "Stub!".
>
> So I decided to do those tests in a way shown on Android developer
> site. I created two projects: first with main application, an second
> for test purposes. I installed those two on emulator, and executed
> tests via:
> <b>adb shell am instrument  -w com.newbay.vault.test/
> android.test.InstrumentationTestRunner</b>
>
> It run tests but, there wasn't very verbose output. I executed next
> command, to include coverage:
> <b>adb shell am instrument  -e coverage true -w com.newbay.vault.test/
> android.test.InstrumentationTestRunner</b>
>
> It created "coverage.ec" file on emulator which I was able to download
> via "adb pull" command.
>
> The problem is I need XML report from JUnit. Also - to generate Emma
> report - two files are needed: "coverage.ec" (which is generated on
> emulator) and "coverage.em" file (metadata) which I cannot find
> anywhere.
>
> Questions are:
> 1. Can I somehow force Android to generate XML report from JUnit test
> results?
>

Try running the tests via Eclipse. There's an "Test Run history" icon on the
"Junit" results pane. Select it and choose "Export" from the resulting menu.
This will save an XML file of the results.


> 2. Where shall I look for metadata file ("coverage.em")?
>

"coverage.em" is generated from your built source code. I believe the 'emma
instr' command can generate it. However, there is an easier way of getting
code coverage results. The latest SDK (version 4 tools, and 1.6 platform or
greater) has built in support for generating emma code coverage. Just set up
your main app and test app as android projects, and then execute the 'ant
coverage' command for your test project. It should do all the necessary
behind-the-scenes compiling, installing, running of the tests, etc

3. Is it possible to successfully run tests without running emulator
> instance?
>

Android tests must be executed on an Android platform - either an Android
device or emulator.


> I've found some posts on Google where "EMMA_INSTRUMENT=true" variable
> was exported. Does this mean, that I have to compile SDK manually with
> this variable defined to turn on "coverage.em" generation?
>

"EMMA_INSTRUMENT=true" is used to get code coverage builds when building the
Android platform source code. Its not applicable when using the SDK - just
use 'ant coverage'


>
> Thanks in advance four your answers
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to