Shifted the ApacheHttpClientMediaWikiApiTest to run using Robolectric (as a unit test) rather than on-device.

This commit is contained in:
Paul Hawke 2017-07-05 20:23:37 -05:00
parent c035b368c4
commit ddce34bc90
2 changed files with 10 additions and 7 deletions

View file

@ -28,6 +28,11 @@ dependencies {
compile "com.google.guava:guava:${GUAVA_VERSION}"
testCompile 'junit:junit:4.12'
testCompile ('org.robolectric:robolectric:3.3.2') {
exclude module: 'guava'
}
testCompile 'com.squareup.okhttp3:mockwebserver:3.8.1'
androidTestCompile 'com.squareup.okhttp3:mockwebserver:3.8.1'
androidTestCompile "com.android.support:support-annotations:${project.supportLibVersion}"
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'

View file

@ -1,12 +1,13 @@
package fr.free.nrw.commons.mwapi;
import android.os.Build;
import android.support.test.runner.AndroidJUnit4;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
@ -25,11 +26,8 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
/*
* XML for individual tests was captured by hand from the API sandbox -
* https://en.wikipedia.org/wiki/Special:ApiSandbox
*/
@RunWith(AndroidJUnit4.class)
@RunWith(RobolectricTestRunner.class)
@Config(constants = BuildConfig.class)
public class ApacheHttpClientMediaWikiApiTest {
private ApacheHttpClientMediaWikiApi testObject;
@ -226,4 +224,4 @@ public class ApacheHttpClientMediaWikiApiTest {
}
return result;
}
}
}