Wednesday, June 2, 2010

Re: [android-developers] Failing JUnit tests, not breaking my Ant script like I expect?

failonerror only checks the return code of the app it's running.

In this case adb runs correctly so your test doesn't break.

Note however that while adb is not able to return the error code of
the shell command it's running on the device, it's also not the issue
in this case.
"am instrument" does not fail to run, and therefore doesn't return a
bad error code.

What we would need is a program that reads the output of "adb shell am
instrument..." and triggers an error based on the output.

On Wed, Jun 2, 2010 at 9:15 AM, whitemice <markbrady@zedray.co.uk> wrote:
> My continuous integration server runs an Ant script, which calls
> something like:
> /tests/ant run-tests
>
> My JUnit tests run, but with errors:
> run-tests:
>     [echo] run-tests-helper.
>     [echo] Running tests ...
>     [exec]
>     [exec] com.zedray.stuff.FooBarTest:....
>     [exec] com.zedray.stuff.FooBarTest:.....INSTRUMENTATION_RESULT:
> shortMsg=Some error in your code.
>     [exec] INSTRUMENTATION_RESULT:
> longMsg=java.security.InvalidParameterException: Some error in your
> code
>     [exec] INSTRUMENTATION_CODE: 0
>
> The errors are OK, but my build script keeps going (eventually
> publishing my broken app to my testers - bad!).  What I would expect
> is for the instrimentaiton to throw a build error, so my continuous
> integration server (TeamCity in this case) realises that something has
> gone wrong and reports a broken build.  The "failonerror" is already
> set in the relevant macrodef, so I'm not sure what else I can do?
>
> #### /tests/build.xml ####
> <macrodef name="run-tests-helper">
>    <attribute name="emma.enabled" default="false" />
>    <element name="extra-instrument-args" optional="yes" />
>    <sequential>
>        <echo>Running tests ...</echo>
>        <exec executable="${adb}" failonerror="true">
>            <arg value="shell" />
>            <arg value="am" />
>               <arg value="instrument" />
>            <arg value="-w" />
>            <arg value="-e" />
>               <arg value="coverage" />
>               <arg value="@{emma.enabled}" />
>            <extra-instrument-args />
>            <arg value="${manifest.package}/${test.runner}" />
>        </exec>
>    </sequential>
> </macrodef>
>
> Any ideas/suggestions on how to fix this?
>
> Regards
> Mark
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscribe@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>

--
Xavier Ducrohet
Android SDK Tech Lead
Google Inc.

Please do not send me questions directly. Thanks!

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment