mirror of
https://github.com/SimpleMobileTools/Simple-Calculator.git
synced 2024-12-22 13:25:58 +01:00
Make Robolectric tests run
Update Robolectric to 3.3.2 Remove MyTestRunner.class and use RobolectricTestRunner.class instead
This commit is contained in:
parent
a5ffece335
commit
76fdd5317e
@ -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'
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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"));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user