I would like to write, run, and debug JUnit tests that test non-GUI
code that has dependencies on the Android SDK. Is there a simple way
to do that? I'm aware of the instrumentation mechanism, but that seems
to be geared towards testing GUI code. It is also unclear how to use
the instrumentation mechanism with Eclipse and also the debugger.
I've tried simply writing tests using the classes in android.test and
running them via AndroidTestRunner invoked from a button click on an
Activity, but I get the following error when I try to run the
application.

W/dalvikvm(  594): VFY: unable to resolve new-instance 8 (Landroid/
test/AndroidTestRunner;) in Lcom/spike/AndroidSpike$2;

For completeness, here is the complete code for the Activity.

package com.spike;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.test.*;

public class AndroidSpike extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        ((Button)this.findViewById
(R.id.runTestsButton)).setOnClickListener(new OnClickListener() {
                        @Override
                        public void onClick(View v) {
                                AndroidTestRunner runner = new 
AndroidTestRunner();
                                runner.setTest(AllTests.suite());
                                runner.runTest();
                        }
                });
    }
}
--~--~---------~--~----~------------~-------~--~----~
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-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to