Strange errors in Robolectric land...

This commit is contained in:
Bradlee Speice 2014-11-18 00:08:25 -05:00
parent f331f95722
commit 9e63885984
2 changed files with 45 additions and 5 deletions

View File

@ -15,16 +15,19 @@ buildscript {
}
def androidModule = project(':app')
def firstVariant = androidModule.android.applicationVariants.toList().first()
def firstAppVariant = androidModule.android.applicationVariants.toList().first()
//def firstTestVariant = androidModule.android.testVariants.toList().first()
dependencies {
compile androidModule
testCompile firstVariant.javaCompile.classpath
testCompile firstVariant.javaCompile.outputs.files
testCompile firstAppVariant.javaCompile.classpath
testCompile firstAppVariant.javaCompile.outputs.files
//testCompile firstTestVariant.javaCompile.outputs.files
testCompile files(androidModule.plugins.findPlugin("com.android.application").getBootClasspath())
testCompile 'junit:junit:4.+'
testCompile 'org.mockito:mockito-all:+'
testCompile 'org.robolectric:robolectric:+'
}
@ -42,11 +45,11 @@ jacocoTestReport {
def jacocoExcludes = [
"android/**/*"
]
firstVariant.javaCompile.exclude(jacocoExcludes).outputs.files
firstAppVariant.javaCompile.exclude(jacocoExcludes).outputs.files
doFirst {
sourceDirectories = files(androidModule.android.sourceSets.main.java.srcDirs)
classDirectories = firstVariant.javaCompile.outputs.files
classDirectories = firstAppVariant.javaCompile.outputs.files
}
// Back to your regularly scheduled Jacoco

View File

@ -0,0 +1,37 @@
package org.bspeice.minimalbible.test.activity.downloader;
import org.bspeice.minimalbible.activity.downloader.BookListFragment;
import org.bspeice.minimalbible.activity.downloader.DownloadActivity;
import org.crosswire.jsword.book.BookCategory;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import static org.junit.Assert.assertTrue;
/**
* Created by bspeice on 11/17/14.
*/
@RunWith(RobolectricTestRunner.class)
@Config(emulateSdk = 18, manifest = "../app/src/main/AndroidManifest.xml")
public class BookListFragmentTest {
@Before
public void setUp() {
DownloadActivity activity = Robolectric.buildActivity(DownloadActivity.class)
.create().start().visible().get();
BookListFragment fragment = BookListFragment.newInstance(BookCategory.BIBLE);
activity.getSupportFragmentManager()
.beginTransaction()
.add(fragment, null)
.commit();
}
@Test
public void testItsWorking() {
assertTrue(true);
}
}