mercredi 25 novembre 2015

Unit Test Android Service

I am trying to test my Service using "ServiceTestCase" framework as following:

@RunWith(AndroidJUnit4.class)
public class testTts extends ServiceTestCase<TtsLbEngine> {

    public testTts() {
        super(TtsLbEngine.class);
    }

    @Before
    public void setUp() throws Exception {
        super.setUp();
    }

    @After
    public void tearDown() throws Exception {
        super.tearDown();
    }


    @Test
    public void testOnCreate() throws Exception {
        Intent intent = new Intent(getSystemContext(), TtsLbEngine.class);
        intent.setClass(getSystemContext(), TtsLbEngine.class);
        startService(intent);
        assertNotNull(getService());

    }
}

The problem is that the service is Null. Can you please advise.

Aucun commentaire:

Enregistrer un commentaire