I'm using the robolectric unit test.I'm facing the following issue when i try to use async task with web service call.
my build.gradle config
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
useLibrary 'org.apache.http.legacy'
testOptions {
unitTests.all {
// configure the set of classes for JUnit tests
include '/*Test.class'
//exclude '/espresso/*/.class'
// configure max heap size of the test JVM
maxHeapSize = "2048m"
systemProperty 'robolectric.dependency.repo.url', 'https://local-mirror/repo'
systemProperty 'robolectric.dependency.repo.id', 'local'
}
}
productFlavors {
// Define separate dev and prod product flavors.
dev {
// dev utilizes minSDKVersion = 21 to allow the Android gradle plugin
// to pre-dex each module and produce an APK that can be tested on
// Android Lollipop without time consuming dex merging processes.
minSdkVersion 21
}
prod {
// The actual minSdkVersion for the application.
minSdkVersion 18
}
}
defaultConfig {
applicationId "mypackage name"
targetSdkVersion 23
versionCode 8
versionName "1.6.0"
multiDexEnabled true
}
dependencies{
testCompile ('junit:junit:4.12')
testCompile 'org.hamcrest:hamcrest-core:1.1'
testCompile 'org.hamcrest:hamcrest-library:1.1'
testCompile 'org.hamcrest:hamcrest-integration:1.1'
testCompile "org.robolectric:robolectric:3.0"
testCompile "org.robolectric:shadows-multidex:3.0"
}
this is my LoginActivityTest
@Test
public void loginSucess(){
LoginActivity loginActivity = Robolectric.setupActivity(LoginActivity.class);
emailView.setText("testpay4@gmail.com");
passwordView.setText("123456");
assertNotNull("email view is null",emailView);
assertNotNull("password view is null",passwordView);
assertNotNull("login buton is null",btnLogin);
assertEquals("login sucess",Constants.testSucess,loginActivity.attemptLoginWithTest(emailView.getText().toString(),passwordView.getText().toString()));
btnLogin.performClick();
ShadowApplication application = shadowOf(RuntimeEnvironment.application);
assertThat("Next activity has started", application.getNextStartedActivity(), is(notNullValue()));
}
When i run the login activity i getting the issue with this**
" java.lang.NoClassDefFoundError: javax/net/ssl/DistinguishedNameParser"**