On Thu, Jan 29, 2009 at 6:12 PM, Xavier Ducrohet <[email protected]> wrote:
>
> You will never really be able to just use the default Run as JUnit test 
> action.
>
> This is because this setups up the tests to run using the system
> library of the project which, for Android project, is android.jar.
> android.jar in the SDK is only stubbed methods/classes, and contains no code.
>
> You can run unit tests by setting up Eclipse using the follow
> instructions: http://code.google.com/android/kb/troubleshooting.html#addjunit
>
> Note that this will only work for tests not using the Android APIs.
>
Thanks. But most likely most of my classes will use android APIs, so
using this to unit-test is not that common, right?
Or I am mis-understanding the condition.
I would like to have 1 way to unit-test my android code.


> If you wish to run true android test, please use instrumentations
> running on the device.
> See 
> http://code.google.com/android/reference/android/test/InstrumentationTestRunner.html
> for more information.
>



> The information from Diego to setup the test runners for ApiDemos is
> good, except that you don't need to create a new project and copy
> things over, you can simply create a project for the existing source
> (you will need to link the apidemos project in your build path).
>

Thank you. I have followed Diego instructions, and I finally get that to work.
But you mention that there a way not to create a new project.
Can you please tell me how to do that?

I have create an 'apidemos' project in eclipse, but the 'tests'
directory is not in the build path. Hence they are not compile.

So what should I do to run the code 'tests' code without creating a
new project like Diego described.

Thank you for any tips.


> Xav
>
> On Thu, Jan 29, 2009 at 5:44 PM, [email protected] <[email protected]> wrote:
>>
>> Thanks. But can you please tell me if it is possible to
>> * run junit test within eclipse using the 'Debug->Run as Junit Test'?
>> * run junit test as part of the ant script? (i.e. automatically via
>> command line)
>>
>> Thank you.
>>
>>
>> On Jan 29, 3:08 pm, Diego Torres Milano <[email protected]> wrote:
>>> This may help 
>>> youhttp://dtmilano.blogspot.com/2008/11/android-testing-on-android-platf...
>>>
>>> On Jan 29, 1:55 am, "[email protected]" <[email protected]> wrote:
>>>
>>> > Hi,
>>>
>>> > I am trying to run Junit test case for the android APIDemo project
>>> > under eclipse.
>>>
>>> > I create an eclipse project from the APIDemo source, it compiles fine
>>> > and then I did:
>>> > 1. Debug->Run as Junit tests
>>>
>>> > But I get this error:
>>> > 'Lanuching AllTests' has encountered a problem.
>>> > Cannot connect to VM.
>>>
>>> > And I find this in the .log file in eclipse:
>>> > !ENTRY org.eclipse.core.net 1 0 2009-01-28 15:03:52.799
>>> > !MESSAGE System property http.nonProxyHosts has been set to
>>> > local|*.local|169.25
>>> > 4/16|*.169.254/16 by an external source. This value will be
>>> > overwritten
>>> > using th
>>> > e values from the preferences
>>>
>>> > !ENTRY org.eclipse.jdt.launching 4 120 2009-01-28 15:04:03.269
>>> > !MESSAGE Cannot connect to VM
>>> > !STACK 0
>>> > java.net.SocketException: Socket closed
>>> >         at java.net.PlainSocketImpl.socketAccept(Native Method)
>>> >         at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:384)
>>> >         at java.net.ServerSocket.implAccept(ServerSocket.java:450)
>>> >         at java.net.ServerSocket.accept(ServerSocket.java:421)
>>> >         at
>>> > org.eclipse.jdi.internal.connect.SocketTransportService.accept(Socket
>>> > TransportService.java:95)
>>> >         at
>>> > org.eclipse.jdi.internal.connect.SocketTransportImpl.accept(SocketTra
>>> > nsportImpl.java:56)
>>> >         at
>>> > org.eclipse.jdi.internal.connect.SocketListeningConnectorImpl.accept(
>>> > SocketListeningConnectorImpl.java:135)
>>> >         at
>>> > org.eclipse.jdt.internal.launching.StandardVMDebugger$ConnectRunnable
>>> > run(StandardVMDebugger.java:107)
>>> >         at java.lang.Thread.run(Thread.java:613)
>>>
>>> > !ENTRY org.eclipse.jdt.launching 4 120 2009-01-28 15:23:53.932
>>> > !MESSAGE Cannot connect to VM
>>> > !STACK 0
>>> > java.net.SocketException: Socket closed
>>> >         at java.net.PlainSocketImpl.socketAccept(Native Method)
>>> >         at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:384)
>>> >         at java.net.ServerSocket.implAccept(ServerSocket.java:450)
>>> >         at java.net.ServerSocket.accept(ServerSocket.java:421)
>>> >         at
>>> > org.eclipse.jdi.internal.connect.SocketTransportService.accept(Socket
>>> > TransportService.java:95)
>>> >         at
>>> > org.eclipse.jdi.internal.connect.SocketTransportImpl.accept(SocketTra
>>> > nsportImpl.java:56)
>>> >         at
>>> > org.eclipse.jdi.internal.connect.SocketListeningConnectorImpl.accept(
>>> > SocketListeningConnectorImpl.java:135)
>>> >         at
>>> > org.eclipse.jdt.internal.launching.StandardVMDebugger$ConnectRunnable
>>> > run(StandardVMDebugger.java:107)
>>> >         at java.lang.Thread.run(Thread.java:613)
>>>
>>> > Thank you for any help.
>> >
>>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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