Need help in running the android junit test case for andriod APIDemo in eclipse

by Xavier Ducrohet » Fri, 30 Jan 2009 10:12:55 GMT


Sponsored Links
 ou 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.

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).

Xav

On Thu, Jan 29, 2009 at 5:44 PM, ying...@gmail.com <ying...@gmail.com> wrote:

--~--~---------~--~----~------------~-------~--~----~



Need help in running the android junit test case for andriod APIDemo in eclipse

by ying lcs » Fri, 30 Jan 2009 10:25:45 GMT


 n Thu, Jan 29, 2009 at 6:12 PM, Xavier Ducrohet <x...@google.com> wrote:
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.






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.



--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Need help in running the android junit test case for andriod APIDemo in eclipse

by Xavier Ducrohet » Fri, 30 Jan 2009 10:31:50 GMT


 sing the "new android project" wizard, you can create a project from
existing source.
This is probably what you used to create a project for ApiDemos. Just
use it again for the tests project (point the wizard to
<sdk>/samples/ApiDemos/tests).

The compilation problem is because the tests project doesn't know the
ApiDemos classes until you tell it where they are.
Right click the tests project in the package Explorer and choose Build
Path > Configure Build Path.
In the "Projects" tab, click Add and choose your ApiDemos project.

Because deployment of instrumentation projects is not supported in ADT
you will have install ApiDemos and your test project manually.

We do intend to improve this workflow in the future.

Xav

On Thu, Jan 29, 2009 at 6:25 PM, ying lcs <ying...@gmail.com> wrote:

--~--~---------~--~----~------------~-------~--~----~



Need help in running the android junit test case for andriod APIDemo in eclipse

by ying lcs » Sat, 31 Jan 2009 04:17:36 GMT


 hank you.  Xavier,

Can you please tell me if this will run other vanilla junit test
cases? The ones just inherit from Junit framework, not the ones which
are sub-classed from Google TestCase classes?

Thank you.

On Thu, Jan 29, 2009 at 6:31 PM, Xavier Ducrohet <x...@google.com> wrote:

--~--~---------~--~----~------------~-------~--~----~



Need help in running the android junit test case for andriod APIDemo in eclipse

by ying lcs » Sat, 31 Jan 2009 06:21:13 GMT


 i,

I tried that again, but it does not work now, for some reason.

I did load 'ApiDemos' project first, but I don't see the 'Test for Api
Demo' in the 'Instrumentation.' screen.
Then, I manually load the 'ApiDemosTest2' project again, I still don't
see the 'Test for Api Demo'.

But from the Eclipse output, I do see that both apk has been installed.

Any idea why it does not work?
Thank you for any help.

[2009-01-30 14:09:26 - ApiDemos] HOME is up on device 'emulator-5554'
[2009-01-30 14:09:26 - ApiDemos] Uploading ApiDemos.apk onto device
'emulator-5554'
[2009-01-30 14:09:28 - ApiDemos] Installing ApiDemos.apk...
[2009-01-30 14:09:37 - ApiDemos] Success!
[2009-01-30 14:09:38 - ApiDemos] Starting activity
com.example.android.apis.ApiDemos on device
[2009-01-30 14:09:39 - ApiDemos] ActivityManager: Starting: Intent {
comp={com.example.android.apis/com.example.android.apis.ApiDemos} }
[2009-01-30 14:09:39 - ApiDemos] Attempting to connect debugger to
'com.example.android.apis' on port 8613
[2009-01-30 14:15:00 - ApiDemosTest2] ------------------------------
[2009-01-30 14:15:00 - ApiDemosTest2] Android Launch!
[2009-01-30 14:15:00 - ApiDemosTest2] adb is running normally.
[2009-01-30 14:15:00 - ApiDemosTest2] Launching:
com.example.android.apis.tests.Dummy
[2009-01-30 14:15:00 - ApiDemosTest2] Automatic Target Mode: using
existing emulator: emulator-5554
[2009-01-30 14:15:00 - ApiDemosTest2] Uploading ApiDemosTest2.apk onto
device 'emulator-5554'
[2009-01-30 14:15:00 - ApiDemosTest2] Installing ApiDemosTest2.apk...
[2009-01-30 14:15:03 - ApiDemosTest2] Success!
[2009-01-30 14:15:03 - ApiDemosTest2] Starting activity
com.example.android.apis.tests.Dummy on device
[2009-01-30 14:15:04 - ApiDemosTest2] ActivityManager: Starting:
Intent {
comp={com.example.android.apis.tests/com.example.android.apis.tests.Dummy}
}
[2009-01-30 14:15:04 - ApiDemosTest2] Attempting to connect debugger
to 'com.example.android.apis.tests' on port 8617


On Thu, Jan 29, 2009 at 6:31 PM, Xavier Ducrohet <x...@google.com> wrote:

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Droid X Hands-on Review! | Droid X 鈥? Blog dedicated to Droid X News and Accessories!

N1 vs. Droid X vs. HTC Evo 4G.
which is better?

http://droidx.net/droid-x-news/droid-x-hands-on-review/

---
This message was sent by eko.m...@gmail.com via http://addthis.com.  Please 
note that AddThis does not verify email addresses.

Make sharing easier with the AddThis Toolbar:  
http://www.addthis.com/go/toolbar-em

-- 
"Indonesian Android Community [id-android]" 

2. BConnect Tawarkan AHA

Karena saya lihat juga dibahas di sini, saya posting juga ya.
===

Bakrie Connectivity (BConnect), unit usaha baru Bakrie Telecom, hari ini 
meluncurkan layanan EvDO yang diberi nama AHA. Kecepatan akses yang dijanjikan 
mencapai 3,1 Mbps (download) dan 1,8 Mbps (upload).

Ada tiga paket layanan:
1. Paket ekonomis, kecepatan hingga 200 kbps, dengan tarif Rp 4 ribu per hari 
atau Rp 80 ribu per bulan.

2. Paket dinamis, kecepatan hingga 600 kbps, dengan tarif Rp 6 ribu per hari 
atau Rp 110 ribu per bulan.

3. Paket fantastis, kecepatan hingga 3,1 Mbps, dengan tarif Rp 10 ribu per hari 
atau Rp 200 ribu per bulan.

Ada pula tarif eceran Rp 150 per menit dan Rp 0,5 per KB.

{*filter*}tara layanan tersedia di Surabaya, lalu Jogja, Semarang, Solo, dan Malang. 
Berikutnya, Bogor dan kota-kota lain.

Btw busway, sampai detik ini saya belum mencoba layanan AHA. Semoga saja 
benar-benar cepat, stabil, dan tahan lama. Pengalaman dengan EvDO Smart, 
awalnya bagus, tetapi sekitar sebulan setelah peluncuran langsung memble.


Hsw

-- 
"Indonesian Android Community [id-android]" 

Join:  http://www.***.com/ 
Moderator: id.andr...@gmail.com
ID Android Developer:  http://www.***.com/ 
ID Android Surabaya:  http://www.***.com/ 
ID Android on FB:  http://www.***.com/ 

3. Strange behavior of the panel for developers of Android Market.

4. AIDL, Binder, ResultReceiver, and Performance

5. geocoder problem

6. Hang installing unit tests

7. milestone sering restart sendiri