1

I'm trying to do Android unit testing for the first tme and I encounter a problem I can't seem to solve : only one of my test classes is ran, I'm not able to run test classes related to Activity testing, and even asserting true=false in them doesn't display an error.

My testing project is composed of three source files :

  • A test file for a class in my project (subclass of AndroidTestCase)
  • A test file for my first activity, LoginActivity (subclass of ActivityInstrumentationTestCase2)
  • A test file for another activity, EditUserActivity (once again subclass of ActivityInstrumentationTestCase2)

I used the following tutorial : http://forum.frandroid.com/topic/13831-traduc-de-tuto-les-tests-unitaires/ (in French but the code is in English)

And first read the following answer on StackOverflow : Trying to run Android JUnit tests in Eclipse fails? however it doesn't seems to be my problem

The code for the last test class is the following :

package com.imci.ica.test;

import com.imci.ica.EditUserActivity;
import android.test.ActivityInstrumentationTestCase2;

public class EditUserActivityTest extends
        ActivityInstrumentationTestCase2<EditUserActivity> {
    EditUserActivity mActivity;

    public EditUserActivityTest() {
        super("com.imci.ica", EditUserActivity.class);
    }

    @Override
    protected void setUp() throws Exception {
        super.setUp();
        mActivity = this.getActivity();
    }

    public void testTest() {
        assertEquals(true, false);
    }
}

Thanks in advance for your help!

Community
  • 1
  • 1
Aweb
  • 174
  • 3
  • 15

2 Answers2

0

I don't understand why, but I had to move the Eclipse project's files, so I closed the project, moved them and imported the project back, and now all the tests are checked, so my problem's fixed. If it can help somebody...

Aweb
  • 174
  • 3
  • 15
0

For me, I found that one testing class was crashing. I forgot to added non-argument constructor. Fixing that, all tests are run.

Abdalrahman Shatou
  • 4,550
  • 6
  • 50
  • 79