mirror of
https://github.com/MinimalBible/MinimalBible
synced 2025-07-02 22:34:44 -04:00
Get Robolectric test support working!
This commit is contained in:
@ -6,6 +6,7 @@ apply plugin: 'com.github.kt3k.coveralls'
|
||||
evaluationDependsOn(":app")
|
||||
|
||||
buildscript {
|
||||
ext.kotlin_version = '0.10.770'
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
@ -13,6 +14,7 @@ buildscript {
|
||||
dependencies {
|
||||
// Version lock for https://github.com/kt3k/coveralls-gradle-plugin/issues/27
|
||||
classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.0.1x'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,6 +22,7 @@ repositories {
|
||||
maven {
|
||||
url 'http://repository.jetbrains.com/repo'
|
||||
}
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
// TODO: Make sure we test against the Debug variant
|
||||
@ -51,9 +54,11 @@ dependencies {
|
||||
testCompile firstVariant.javaCompile.classpath
|
||||
testCompile firstVariant.javaCompile.outputs.files
|
||||
testCompile files(androidModule.plugins.findPlugin("com.android.application").getBootClasspath())
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
}
|
||||
|
||||
def buildExcludeTree(path, excludes) {
|
||||
//noinspection GroovyAssignabilityCheck
|
||||
def tree = fileTree(path).exclude(excludes)
|
||||
tree
|
||||
}
|
||||
@ -87,6 +92,6 @@ coveralls {
|
||||
}
|
||||
|
||||
tasks.withType(Test) {
|
||||
scanForTestClasses = false
|
||||
scanForTestClasses = true
|
||||
includes = testIncludes
|
||||
}
|
||||
|
@ -0,0 +1,31 @@
|
||||
package org.bspeice.minimalbible.activity.search;
|
||||
|
||||
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.assertNotNull;
|
||||
|
||||
/**
|
||||
* Right now this is the only Robolectric test. Some clarifications on this should be made:
|
||||
* There's an ongoing issue with the ActionBarDrawerToggle, meaning that the BasicSearch
|
||||
* activity is the only one eligible for testing
|
||||
* (https://github.com/robolectric/robolectric/issues/1424)
|
||||
* <p/>
|
||||
* Additionally, Robolectric only supports up to Jellybean, which is why the emulateSdk.
|
||||
* Finally, in Gradle, tests run relative to app-test, whereas the IDE may try and run
|
||||
* things in the project root. Be careful when changing the manifest location.
|
||||
*/
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(emulateSdk = 18, manifest = "../app/src/main/AndroidManifest.xml")
|
||||
public class BasicSearchTest {
|
||||
|
||||
@Test
|
||||
public void testBuildActivity() {
|
||||
BasicSearch activity = Robolectric.buildActivity(BasicSearch.class)
|
||||
.create().get();
|
||||
assertNotNull(activity);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user