lundi 27 juin 2016

basic android unit testing

I am using Android Studio and I wrote an ultra basic test for the MAinActivity class. I inherited MainActivityTest from extends ActivityInstrumentationTestCase2<MainActivity> and I want to test

private MainActivity mMainActivityTest;
public void testPreconditions() {
        assertNotNull("mMainActivityTest is null", mMainActivityTest);
    }

using gradle unit testing, without having to launch any emulator.

When I run the test, I get no red or green color bar, and whatever I choose assertNotNull or assertNull, I always get

External tasks execution finished 'cleanTest test --tests "com.my.app.MainActivityTest.testPreconditions"

how can I do correct unit test ?

Aucun commentaire:

Enregistrer un commentaire