Created
November 11, 2017 01:59
-
-
Save donnfelker/4d607025340e1fc7a13158cd89b377d4 to your computer and use it in GitHub Desktop.
Integrating Robolectric 3 with Android Studio 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies { | |
testCompile 'junit:junit:4.12' | |
testCompile 'org.robolectric:robolectric:3.0' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I tried running, but it is not working. Check this.