use roboelectric 3.0-rc3, use upstream GradleTestRunner

This commit is contained in:
Daniel Schaal 2015-06-19 20:33:25 +02:00
parent 0410227822
commit 9959063d17
4 changed files with 4 additions and 34 deletions

View file

@ -63,6 +63,6 @@ dependencies {
compile 'de.greenrobot:greendao-generator:1.3.1@jar'
compile 'org.freemarker:freemarker:2.3.18@jar'
testCompile 'org.robolectric:robolectric:2.4'
testCompile 'org.robolectric:robolectric:3.0-rc3'
testCompile 'junit:junit:4.+'
}

View file

@ -15,8 +15,6 @@
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<uses-sdk android:targetSdkVersion="18" /> <!-- For Unit testing -->
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"

View file

@ -1,29 +0,0 @@
package de.luhmer.owncloudnewsreader.junit_tests;
import org.junit.runners.model.InitializationError;
import org.robolectric.AndroidManifest;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import org.robolectric.res.Fs;
public class RobolectricGradleTestRunner extends RobolectricTestRunner {
public RobolectricGradleTestRunner(Class<?> testClass) throws InitializationError {
super(testClass);
}
@Override
protected AndroidManifest getAppManifest(Config config) {
String myAppPath = RobolectricGradleTestRunner.class.getProtectionDomain()
.getCodeSource()
.getLocation()
.getPath();
String manifestPath = myAppPath + "../../../src/main/AndroidManifest.xml";
String resPath = myAppPath + "../../../src/main/res";
String assetPath = myAppPath + "../../../src/main/assets";
return createAppManifest(Fs.fileFromPath(manifestPath),
Fs.fileFromPath(resPath),
Fs.fileFromPath(assetPath));
}
}

View file

@ -8,10 +8,12 @@ import org.junit.Test;
import org.junit.rules.Stopwatch;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricGradleTestRunner;
import org.robolectric.annotation.Config;
import java.util.List;
import de.luhmer.owncloudnewsreader.BuildConfig;
import de.luhmer.owncloudnewsreader.NewsReaderListActivity;
import de.luhmer.owncloudnewsreader.database.DatabaseConnectionOrm;
import de.luhmer.owncloudnewsreader.database.DatabaseHelperOrm;
@ -20,9 +22,8 @@ import de.luhmer.owncloudnewsreader.database.model.Feed;
import static org.junit.Assert.*;
@Config(emulateSdk=18)
@RunWith(RobolectricGradleTestRunner.class)
@Config(constants = BuildConfig.class, sdk = 21)
public class TestDbTest {
private NewsReaderListActivity activity;