1

I have create new android studio project and below is the gradle file where i didnt changed anything apart from compileSDKVersion

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.0"
    defaultConfig {
        applicationId "retailstore.android.com.tddandroid"
        minSdkVersion 15
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:24.0.0'
    testCompile 'junit:junit:4.12'

    // import roboeletric

    testCompile "org.robolectric:robolectric:3.3.2"


}

Android i wrote my first roboeletric test as below :

@RunWith(RobolectricTestRunner.class)
public class MainActivityTest {

    @Test
    public void clickingLogin_shouldStartLoginActivity() {

        assertThat("").isEqualTo("");
    }
}

I m running test via command prompt as below :

enter image description here

KOTIOS
  • 11,177
  • 3
  • 39
  • 66

1 Answers1

1

Make sure you check with robolectric version is compatible with with version of java :

Robolectric 24+ api version need JDK 1.8 .

It may be possible that 1.7 and 1.8 both JDK version are been installed on your machine for mac do check which all version are being installed with below command :

$ ls -l /Library/Java/JavaVirtualMachines/
total 0
drwxr-xr-x  3 root  wheel  102 Nov  4  2013 jdk1.7.0_45.jdk
drwxr-xr-x  3 root  wheel  102 Jan 16 14:13 jdk1.8.0_25.jdk

Switch the JDK version appropriately

KOTIOS
  • 11,177
  • 3
  • 39
  • 66