Ecplipse Test Failed target class not found

Common bugs/problems with the Android SDK the Emulator and the ADT-Plugin.

Ecplipse Test Failed target class not found

Postby Panciz » Tue Nov 23, 2010 10:47 am

Hi,

I tried to write a simple test case for my activity but when i run it i get :

Syntax: [ Download ] [ Hide ]
  1. 11-23 10:28:13.919: ERROR/dalvikvm(252): Could not find class 'com.android.myapp.MyActivity', referenced from method com.android.myapp.test.DummyTest.<init> 
  2. 11-23 10:28:13.978: ERROR/dalvikvm(252): Could not find class 'com.android.myapp.MyActivity', referenced from method com.android.myapp.test.DummyTest.setUp 


This is the code of the test :
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package com.android.dpoletti.myeconomy.test;
  2. ...
  3. public class DummyTest extends ActivityInstrumentationTestCase2<MyActivity> {
  4.  
  5.         private MyActivity mActivity;
  6.         private TextView mView;
  7.         private String resourceString;
  8.  
  9.         public DummyTest() {
  10.                 super("com.android.myapp", MyActivity.class);
  11.         }
  12.  
  13.         @Override
  14.         protected void setUp() throws Exception { super.setUp();
  15.                 mActivity = this.getActivity();
  16.                 mView = (TextView) mActivity
  17.                                 .findViewById(com.android.myapp.R.id.label_no_expense);
  18.                 resourceString = mActivity
  19.                                 .getString(com.android.myapp.R.string.label_no_expense); }
  20.  
  21.         public void testPreconditions() {       assertNotNull(mView); }
  22.         public void testText() { assertEquals(resourceString, (String) mView.getText()); }
  23. }
  24.  
  25.  
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


I managed to run the HelloAndroid simple test and this is not different, the only problem may be that MyActivity uses an external library and depends to an external project, but I've already added the same dependencies to the test project.

Can someone help me??

thanks
Panciz
Once Poster
Once Poster
 
Posts: 1
Joined: Wed Sep 29, 2010 9:19 pm

Top

Return to SDK/ADT/Emulator Problems

Who is online

Users browsing this forum: Exabot [Bot] and 8 guests