Merge pull request #25 from trubitsyn/master
Make Robolectric tests run
This commit is contained in:
commit
4a47d302d2
3 changed files with 6 additions and 25 deletions
|
@ -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 a new issue