Hi Xav, Thanks for the tip, I'm still having trouble setting up the test project;
File New Android Project Create new android project Create Project from existing source android/android-sdk-linux_x86-1.1_r1/samples/ApiDemos/tests ! No activity name defined in /home/gavin/Work/android/android-sdk-linux_x86-1.1_r1/samples/ApiDemos/tests/AndroidManifest.xml. I understand that I have to add ApiDemos to the build path but I have to create the project first. Apologies if this is a bit of a silly question, I imagine the answer is right in front of me but I can't work it out. Kind regards, Gavin On Fri, Mar 6, 2009 at 10:40 PM, Xavier Ducrohet <[email protected]> wrote: > > The only way to test code that uses Android API is on a device or emulator. > > Look at instrumentation projects such as the ApiDemos test project > (samples/ApiDemos/tests/) > > You will need to create an Eclipse project for ApiDemos and one of the > test project. > ADT doesn't fully support this at this point, so you'll need to add > the ApiDemos project to the build path of the test project so that it > compiles. > > You then need to install both apk on the device, and use the "am > instrument ..." command on the device (through adb shell). > More information at > > http://developer.android.com/reference/android/test/InstrumentationTestRunner.html > > Xav > > On Fri, Mar 6, 2009 at 1:24 PM, Gavin Aiken <[email protected]> > wrote: > > Hi Bo, > > > > Did you resolve this issue? I'm having a similar problem. > > > > My test suite is a separate eclipse project, I need to test my android > > program against a desktop Java program in order to verify that I have > ported > > the application correctly. > > > > To so this I need to use classes from both the JAI library and Android > > library. > > > > My test package is currently setup as a java project, I assumed the JAI > > library wouldn't compile to dex but that the android classes would > compile > > to java class files. I'm guessing that the latter is incorrect as any > > methods I call return a stub error; > > > > 60. return Bitmap.createBitmap(pixels, 0, width, width, height, > > Bitmap.Config.ARGB_8888); > > > > java.lang.RuntimeException: Stub! > > at android.graphics.Bitmap.createBitmap(Bitmap.java:27) > > at > > > uk.ac.ic.doc.gea05.miffed.operators.concreteoperators.binary.TestIdentityTransform.generateBitmap(TestIdentityTransform.java:60) > > > > I'm presuming that I can't get this to work, and submit this comment for > > reference. If there is a way to use Java Libraries in a test with android > > api calls then please let me know! > > > > Gav > > > > > > On Tue, Jan 6, 2009 at 10:07 AM, Bo <[email protected]> wrote: > >> > >> I am trying to run a unit test in Eclipse. I followed Android FAQ > >> (http://code.google.com/android/kb/troubleshooting.html#addjunit) to > >> get JUnit working. Unfortunately, it works only if tested code does > >> not reference any android classes. As soon as it does, I get the > >> following exception, when running the test (if the class in question > >> implements Parcelable): > >> > >> Caused by: java.lang.ClassNotFoundException: android.os.Parcelable > >> at java.net.URLClassLoader$1.run(URLClassLoader.java:200) > >> at java.security.AccessController.doPrivileged(Native Method) > >> at java.net.URLClassLoader.findClass(URLClassLoader.java:188) > >> at java.lang.ClassLoader.loadClass(ClassLoader.java:316) > >> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:288) > >> at java.lang.ClassLoader.loadClass(ClassLoader.java:251) > >> at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:374) > >> ... 33 more > >> > >> I tried including android.jar file explicitly, but then I got an > >> exception claiming that RectF (an instance variable in my class) is a > >> stub. Anybody knows how to setup Eclipse to run a unit test with > >> classes that either implement, extend or use android classes? > >> > >> > >> > > > > > > > > > > > > > -- > Xavier Ducrohet > Android Engineer, Google. > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

