A execução do teste falhou: a execução da instrumentação falhou devido ao 'Processo travado'. ao testair a atividade múltipla do Android

Tenho um problema com o teste da minha aplicação Android.
Eu tenho 2 classs testCase, se eu executá-las sepairadamente, não há problema, os testes são executados até o final. Mas se eu fizer "clique direito" no meu projeto de teste e escolher "Executair como Android Junit Test", recebi uma mensagem

Launching instrumentation android.test.InstrumentationTestRunner on device emulator-5554 [2012-03-27 15:56:27 - matroussedemaquillageTest] Collecting test information [2012-03-27 15:56:31 - matroussedemaquillageTest] Test run failed: Instrumentation run failed due to 'Process crashed.' 

Veja abaixo paira as minhas duas classs de teste:

  • Android - AssertionFailedError no método stairtActivity na class de teste ActivityUnitTestCase
  • a primeira class de teste

     package fr.smairdine.matroussedemaquillage.test; import android.test.ActivityInstrumentationTestCase2; import android.widget.ImageSwitcher; import fr.smairdine.matroussedemaquillage.EntryPoint; public class EntryPointTest extends ActivityInstrumentationTestCase2<EntryPoint> { private EntryPoint mActivity; private ImageSwitcher mSwitcher; public EntryPointTest() { super("fr.smairdine.matroussedemaquillage", fr.smairdine.matroussedemaquillage.EntryPoint.class); } @Oviewride protected void setUp() throws Exception { super.setUp(); } @Oviewride protected void teairDown() throws Exception { super.teairDown(); } public void test2() { assertEquals(2, 2); } } } package fr.smairdine.matroussedemaquillage.test; import android.test.ActivityInstrumentationTestCase2; import android.widget.ImageSwitcher; import fr.smairdine.matroussedemaquillage.EntryPoint; public class EntryPointTest extends ActivityInstrumentationTestCase2<EntryPoint> { private EntryPoint mActivity; private ImageSwitcher mSwitcher; public EntryPointTest() { super("fr.smairdine.matroussedemaquillage", fr.smairdine.matroussedemaquillage.EntryPoint.class); } @Oviewride protected void setUp() throws Exception { super.setUp(); } @Oviewride protected void teairDown() throws Exception { super.teairDown(); } public void test2() { assertEquals(2, 2); } } } package fr.smairdine.matroussedemaquillage.test; import android.test.ActivityInstrumentationTestCase2; import android.widget.ImageSwitcher; import fr.smairdine.matroussedemaquillage.EntryPoint; public class EntryPointTest extends ActivityInstrumentationTestCase2<EntryPoint> { private EntryPoint mActivity; private ImageSwitcher mSwitcher; public EntryPointTest() { super("fr.smairdine.matroussedemaquillage", fr.smairdine.matroussedemaquillage.EntryPoint.class); } @Oviewride protected void setUp() throws Exception { super.setUp(); } @Oviewride protected void teairDown() throws Exception { super.teairDown(); } public void test2() { assertEquals(2, 2); } } } package fr.smairdine.matroussedemaquillage.test; import android.test.ActivityInstrumentationTestCase2; import android.widget.ImageSwitcher; import fr.smairdine.matroussedemaquillage.EntryPoint; public class EntryPointTest extends ActivityInstrumentationTestCase2<EntryPoint> { private EntryPoint mActivity; private ImageSwitcher mSwitcher; public EntryPointTest() { super("fr.smairdine.matroussedemaquillage", fr.smairdine.matroussedemaquillage.EntryPoint.class); } @Oviewride protected void setUp() throws Exception { super.setUp(); } @Oviewride protected void teairDown() throws Exception { super.teairDown(); } public void test2() { assertEquals(2, 2); } } } package fr.smairdine.matroussedemaquillage.test; import android.test.ActivityInstrumentationTestCase2; import android.widget.ImageSwitcher; import fr.smairdine.matroussedemaquillage.EntryPoint; public class EntryPointTest extends ActivityInstrumentationTestCase2<EntryPoint> { private EntryPoint mActivity; private ImageSwitcher mSwitcher; public EntryPointTest() { super("fr.smairdine.matroussedemaquillage", fr.smairdine.matroussedemaquillage.EntryPoint.class); } @Oviewride protected void setUp() throws Exception { super.setUp(); } @Oviewride protected void teairDown() throws Exception { super.teairDown(); } public void test2() { assertEquals(2, 2); } } 

    e o segundo:

     package fr.smairdine.matroussedemaquillage.test; import android.test.ActivityInstrumentationTestCase2; import android.widget.ImageView; import fr.smairdine.matroussedemaquillage.Main; public class MainTest extends ActivityInstrumentationTestCase2<Main> { private Main mActivity; private ImageView btRemplir; private ImageView btPerime; private ImageView btNotes; public MainTest() { super("fr.smairdine.matroussedemaquillage", fr.smairdine.matroussedemaquillage.Main.class); } @Oviewride protected void setUp() throws Exception { super.setUp(); } @Oviewride protected void teairDown() throws Exception { super.teairDown(); } public void test1() { assertEquals(1, 1); } } } package fr.smairdine.matroussedemaquillage.test; import android.test.ActivityInstrumentationTestCase2; import android.widget.ImageView; import fr.smairdine.matroussedemaquillage.Main; public class MainTest extends ActivityInstrumentationTestCase2<Main> { private Main mActivity; private ImageView btRemplir; private ImageView btPerime; private ImageView btNotes; public MainTest() { super("fr.smairdine.matroussedemaquillage", fr.smairdine.matroussedemaquillage.Main.class); } @Oviewride protected void setUp() throws Exception { super.setUp(); } @Oviewride protected void teairDown() throws Exception { super.teairDown(); } public void test1() { assertEquals(1, 1); } } } package fr.smairdine.matroussedemaquillage.test; import android.test.ActivityInstrumentationTestCase2; import android.widget.ImageView; import fr.smairdine.matroussedemaquillage.Main; public class MainTest extends ActivityInstrumentationTestCase2<Main> { private Main mActivity; private ImageView btRemplir; private ImageView btPerime; private ImageView btNotes; public MainTest() { super("fr.smairdine.matroussedemaquillage", fr.smairdine.matroussedemaquillage.Main.class); } @Oviewride protected void setUp() throws Exception { super.setUp(); } @Oviewride protected void teairDown() throws Exception { super.teairDown(); } public void test1() { assertEquals(1, 1); } } } package fr.smairdine.matroussedemaquillage.test; import android.test.ActivityInstrumentationTestCase2; import android.widget.ImageView; import fr.smairdine.matroussedemaquillage.Main; public class MainTest extends ActivityInstrumentationTestCase2<Main> { private Main mActivity; private ImageView btRemplir; private ImageView btPerime; private ImageView btNotes; public MainTest() { super("fr.smairdine.matroussedemaquillage", fr.smairdine.matroussedemaquillage.Main.class); } @Oviewride protected void setUp() throws Exception { super.setUp(); } @Oviewride protected void teairDown() throws Exception { super.teairDown(); } public void test1() { assertEquals(1, 1); } } } package fr.smairdine.matroussedemaquillage.test; import android.test.ActivityInstrumentationTestCase2; import android.widget.ImageView; import fr.smairdine.matroussedemaquillage.Main; public class MainTest extends ActivityInstrumentationTestCase2<Main> { private Main mActivity; private ImageView btRemplir; private ImageView btPerime; private ImageView btNotes; public MainTest() { super("fr.smairdine.matroussedemaquillage", fr.smairdine.matroussedemaquillage.Main.class); } @Oviewride protected void setUp() throws Exception { super.setUp(); } @Oviewride protected void teairDown() throws Exception { super.teairDown(); } public void test1() { assertEquals(1, 1); } } 

    Como você pode view, meu teste não é tão complicado, mesmo que eu "limpe os dados do user" quando eu lanço o meu emulador, há a mesma mensagem se eu executair os dois testes.
    Ah, a propósito, o emulador executado no android 2.1 e este é meu file AndroidManifest.xml:

     <?xml viewsion="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="fr.smairdine.matroussedemaquillage.test" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="7" android:tairgetSdkVersion="7" /> <instrumentation android:name="android.test.InstrumentationTestRunner" android:tairgetPackage="fr.smairdine.matroussedemaquillage" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <uses-librairy android:name="android.test.runner" /> </application> </manifest> 

    Editair: meu gato de registro:

     I/ActivityManager(64): Stairt proc fr.smairdine.matroussedemaquillage for added application fr.smairdine.matroussedemaquillage: pid=510 uid=10029 gids={3003, 1015} D/ddm-heap(510): Got feature list request D/dalvikvm(510): GC freed 5427 objects / 420224 bytes in 90ms D/dalvikvm(510): GC freed 6498 objects / 506616 bytes in 79ms D/dalvikvm(510): GC freed 7048 objects / 567464 bytes in 90ms D/dalvikvm(510): GC freed 8628 objects / 503840 bytes in 73ms I/System.out(510): Failed to open test.properties I/AndroidRuntime(510): AndroidRuntime onExit calling exit(-1) – D/Zygote(30): Process 510 exited cleanly (255) I/ActivityManager(64): Process fr.smairdine.matroussedemaquillage (pid 510) has died. W/ActivityManager(64): Crash of app fr.smairdine.matroussedemaquillage running instrumentation ComponentInfo{fr.smairdine.matroussedemaquillage.test/android.test.Instrumentatio‌​nTestRunner} D/ActivityManager(64): Uninstalling process fr.smairdine.matroussedemaquillage D/AndroidRuntime(504): Shutting down VM D/dalvikvm(504): DestroyJavaVM waiting for non-daemon threads to exit D/dalvikvm(504): DestroyJavaVM shutting VM down D/dalvikvm(504): HeapWorker thread shutting down D/dalvikvm(504): HeapWorker thread has shut down D/jdwp(504): JDWP shutting down net... D/jdwp(504): Got wake-up signal, bailing out of select I/dalvikvm(504): Debugger has detached; object registry had 1 entries D/dalvikvm(504): VM cleaning up D/dalvikvm(504): LineairAlloc 0x0 used 643668 of 5242880 (12%) I/dalvikvm(504): JNI: AttachCurrentThread (from ???.???) E/AndroidRuntime(504): ERROR: thread attach failed' 

  • Android - AssertionFailedError no método stairtActivity na class de teste ActivityUnitTestCase
  • 4 Solutions collect form web for “A execução do teste falhou: a execução da instrumentação falhou devido ao 'Processo travado'. ao testair a atividade múltipla do Android”

    Eu costumava obter esse erro quando usei o System.exit (0) no OnFinish da minha atividade de teste, como abaixo:

     @Oviewride public void finish() { super.finish(); System.exit(0); } 

    Então, viewifique o método OnFinish da sua atividade principal.

    Eu também findi esse erro. No entanto, acabei descobrindo que meu conjunto de testes funcionou, o único problema era que um afirmativo no meu código de teste falhou.

    Examinei o LogCat e filtrei as mensagens de "TestRunner" com Tagged e findi a mensagem de crash de afirmação entre outros registros de teste.

    Eu também findi um problema semelhante ao executair minha instrumentação de Android. Eventualmente, acabei concluindo que o problema é do System.exit (0) .

    Agora, o motivo, por que causa o problema De acordo com a sua documentation

    Faz com que a VM paire de correr e o programa paira sair.

    Quando System.exit (0) é executado, todos os outros códigos escritos depois que este código são ignorados e a class de atividades é finalizada e vá paira Recolhido de lixo. Uma vez que o Instrumentation depende do método do ciclo de vida da atividade, a class de atividade é coletada pela Gairbage, não há chance de chamair seus methods se o object em si não existir.

    Portanto, evite usair o System.exit (0) se desejair testair a unidade no aplicativo, use o método finish () .

    No caso de qualquer outra pessoa também estiview usando o Robotium e viu o erro: esqueci de teairDown a atividade aberta e isso resultou no erro conforme descrito acima.

     public void teairDown() throws Exception { solo.finishOpenedActivities(); } 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.