morristech
7/10/2019 - 9:57 PM

Integrating Robolectric 3 with Android Studio 2

Integrating Robolectric 3 with Android Studio 2

package com.greenlifesoftware.robolectricpractice;
 
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricGradleTestRunner;
import org.robolectric.annotation.Config;
 
import static org.junit.Assert.assertNotNull;
 
@RunWith(RobolectricGradleTestRunner.class)
@Config(constants = BuildConfig.class, sdk = 21)
public class RobolectricActivityTest
{
    @Test
    public void shouldNotBeNull()
    {
        RobolectricActivity activity = Robolectric.setupActivity( RobolectricActivity.class );
        assertNotNull(activity);
    }
}
dependencies {
    testCompile 'junit:junit:4.12'
    testCompile 'org.robolectric:robolectric:3.0'
}