robolectric

Roboletric 4.0.1 keeps throwing Resources$NotFoundException on buildActivity

柔情痞子 提交于 2019-12-07 11:31:24
I am trying to build very simple unittest with roboletric but I can't create the activity. I tried what was suggested on the thread but no success. Resources$NotFoundException when calling Robolectric.buildActivity() Yet, I am using the 4.0.1 version. I wonder if there some extra setup that I need to do. Here's is my gradle: dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support.constraint:constraint-layout:1.1.3' testImplementation 'junit:junit:4.12' androidTestImplementation 'com

How to load .so when using Robolectric?

感情迁移 提交于 2019-12-07 04:41:12
问题 W/Environment: EXTERNAL_STORAGE undefined; falling back to default java.lang.UnsatisfiedLinkError: com.autonavi.amap.mapcore.MapCore.nativeNewInstance(Ljava/lang/String;)J at com.autonavi.amap.mapcore.MapCore.nativeNewInstance(Native Method) at com.autonavi.amap.mapcore.MapCore.<init>(MapCore.java:62) at com.amap.api.mapcore.AMapDelegateImpGLSurfaceView.<init>(AMapDelegateImpGLSurfaceView.java:356) at com.amap.api.mapcore.AMapDelegateImpGLSurfaceView.<init>(AMapDelegateImpGLSurfaceView.java

Is anyone out there using Robolectric without Maven on IntelliJ? [closed]

北城以北 提交于 2019-12-06 23:58:00
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 6 years ago . All the examples of using Robolectric I can find seem to be Maven based. Is anyone not using Maven? If so I'd really like to understand your IntelliJ project setup. Having read this post android-unit-test-approaches it seems sensible to have a tiered approach to unit testig

RobolectricGradleTestRunner vs RobolectricTestRunner.class

自闭症网瘾萝莉.ら 提交于 2019-12-06 20:43:25
问题 In roboelectric when you write your test class you have declare the @RunWith annotation of which there is RobolectricGradleTestRunner and RobolectricTestRunner.class. What is the difference and which one should we use ? Why is there 2 in the first place. If I use RobolectricTestRunner then it does not work for me it says some weird error like : "java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity." However this seems to go away if I use

java.util.ConcurrentModificationException in JUnit tests

五迷三道 提交于 2019-12-06 20:31:59
问题 This one is kind of a shot in the dark. I'm getting the following error occasionally when running my robolectric unit test suite: java.util.ConcurrentModificationException at java.util.LinkedList$ListItr.checkForComodification(LinkedList.java:966) at java.util.LinkedList$ListItr.next(LinkedList.java:888) at org.robolectric.shadows.ShadowResources.getOverlayedThemeValue(ShadowResources.java:294) at org.robolectric.shadows.ShadowResources.findAttributeValue(ShadowResources.java:284) at org

Robolectric 3.0 Nullpointer on DefaultPackageManager.getActivityInfo()

不打扰是莪最后的温柔 提交于 2019-12-06 15:41:38
I try to create a Robolectric test (3.0-rc02) for the following Activity: public class NotificationActivity extends ActionBarActivity { private NotificationFragment fragment; @Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_notification); } } The test is looking like this: @Config(manifest = IConfig.MANIFEST_PATH, emulateSdk = IConfig.SDK_VERSION, reportSdk = IConfig.SDK_VERSION) @RunWith(RobolectricTestRunner.class) public class AbstractFragmentTest { @Test public void test() { Robolectric.buildActivity

Can't capture HTTP request with robolectric

喜欢而已 提交于 2019-12-06 13:47:19
问题 I am trying to capture an http request with Robolectric The method tokenize method sends a request to a server and I just want to test that the post is sent: If I try //Cardtest.java Robolectric.setDefaultHttpResponse(200, "dummy"); card.tokenize(paymentHandler); Robolectric.getSentHttpRequest(0); The I have an empty array error But I know that the request is sent because if I remove the first line I have the following error: Unexpected HTTP call POST If I put log statement it appears that my

android.content.res.Resources$NotFoundException in Robolectric 2.2

ぃ、小莉子 提交于 2019-12-06 09:49:56
问题 I've a View with a custom theme as explained here and that solves the issue described but causes the following error when i call visible() on ActivityController . android.content.res.Resources$NotFoundException: Resource ID #0x7f0c0000 at android.content.res.Resources.getValue(Resources.java:1118) at android.content.res.Resources.loadXmlResourceParser(Resources.java:2304) at android.content.res.Resources.getLayout(Resources.java:934) at android.support.v7.internal.view.SupportMenuInflater

PowerMock + Robolectric + Dagger2

大兔子大兔子 提交于 2019-12-06 08:48:01
I test custom view class which contain: android ui elements some logic static methods callings dagger2 dependencies So i use next tools for testing Robolectric for UI elements mocking unit tests for logic testing PowerMock for static methods mocking Robolectric + PowerMock integration problem is known and solution is known - https://github.com/robolectric/robolectric/wiki/Using-PowerMock But with this solution dagger2 dependencies fail. Attention to code. My custom view: public class ProgressTextView extends TextView { private String defaultText; private int fileSize; private String

Run Android test with Robolectric - dependency error

荒凉一梦 提交于 2019-12-06 03:54:24
I am using Android Studio 1.2 and Windows 7 When running a robolectric test following this example : @RunWith(CustomRobolectricRunner.class) @Config(emulateSdk = 21, reportSdk = 21, constants = BuildConfig.class) public class PasswordProviderTest{ @Test public void testGetPassword() throws Exception { Activity activity = Robolectric.setupActivity(LoginActivity.class); } @Test public void testSetPassword() throws Exception { } } test result or more the error stacktrace: Unable to resolve artifact: Unable to get dependency information: Unable to read the metadata file for artifact 'org