I want to run Unit test with this code:
import com.twitter.sdk.android.core.Callback;
import com.twitter.sdk.android.core.Result;
import com.twitter.sdk.android.core.TwitterException;
import com.twitter.sdk.android.core.models.Tweet;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricGradleTestRunner;
import java.util.List;
import kravtsov.evgeny.clean.entities.Article;
import kravtsov.evgeny.clean.repository.TweetRepository;
import static org.mockito.Mockito.verify;
@RunWith(RobolectricGradleTestRunner.class)
public class GetTopArticlesTest {
private static final TwitterException ANY_EXCEPTION = new TwitterException("Random exception");
private static final long TWEET_ID = 582295217115541505L;
private GetTopArticlesImpl useCase;
@Mock
private TweetRepository model;
@Mock
private Callback<List<Article>> callback;
@Captor
private ArgumentCaptor<Callback> callbackArgumentCaptor;
@Captor
private ArgumentCaptor<Result<List<Article>>> articleArgumentCaptor;
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
useCase = new GetTopArticlesImpl(model);
}
@Test
public void testGetMostRtArticles_failure() throws Exception {
useCase.execute(callback);
verify(model).getTimeline(callbackArgumentCaptor.capture());
Callback<List<Tweet>> callbackApi = callbackArgumentCaptor.getValue();
callbackApi.failure(ANY_EXCEPTION);
verify(callback).failure(ANY_EXCEPTION);
}
}
After starting this test (about 20 secs) Gradle aborts compilation with no exuses:
Information:Gradle: Executing tasks: [:app:generateDebugSources, :app:prepareDebugUnitTestDependencies, :app:mockableAndroidJar, :app:assembleDebug, :app:assembleDebugUnitTest]
Information:28.10.2015 14:24 - Compilation aborted
Simple googling didn't give me any clues. Can someone explain me this problem, please?
Here is build.gradle (module:app) :
buildscript {
repositories {
maven { url 'http://ift.tt/1yvwjVF' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'http://ift.tt/1yvwjVF' }
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "kravtsov.evgeny.clean"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile('com.twitter.sdk.android:twitter:1.9.0@aar') {
transitive = true;
}
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.10.19'
testCompile 'org.robolectric:robolectric:3.0'
}
Aucun commentaire:
Enregistrer un commentaire