Make Robolectric tests run

Update Robolectric to 3.3.2
Remove MyTestRunner.class and use RobolectricTestRunner.class instead
This commit is contained in:
Nikola Trubitsyn 2017-05-09 18:26:05 +03:00
parent a5ffece335
commit 76fdd5317e
3 changed files with 6 additions and 25 deletions

View File

@ -38,7 +38,7 @@ dependencies {
apt 'com.jakewharton:butterknife-compiler:8.0.1'
testCompile 'junit:junit:4.12'
testCompile 'org.robolectric:robolectric:3.0'
testCompile 'org.robolectric:robolectric:3.3.2'
androidTestCompile 'com.android.support:support-annotations:25.3.1'
androidTestCompile 'com.android.support.test:runner:0.5'

View File

@ -1,17 +1,20 @@
package com.simplemobiletools.calculator;
import com.simplemobiletools.calculator.activities.MainActivity;
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 butterknife.ButterKnife;
import static junit.framework.Assert.assertEquals;
@RunWith(MyTestRunner.class)
@Config(constants = BuildConfig.class, manifest = "app/src/main/AndroidManifest.xml", sdk = 21)
@RunWith(RobolectricTestRunner.class)
@Config(constants = BuildConfig.class, sdk = 21)
public class MainActivityTest {
MainActivity activity;

View File

@ -1,22 +0,0 @@
package com.simplemobiletools.calculator;
import org.junit.runners.model.InitializationError;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import org.robolectric.manifest.AndroidManifest;
import org.robolectric.res.Fs;
public class MyTestRunner extends RobolectricTestRunner {
public MyTestRunner(Class<?> testClass) throws InitializationError {
super(testClass);
}
@Override
protected AndroidManifest getAppManifest(Config config) {
return new AndroidManifest(
Fs.fileFromPath("../app/src/main/AndroidManifest.xml"),
Fs.fileFromPath("../app/src/main/res"),
Fs.fileFromPath("../app/src/main/assets"));
}
}