robolectric

Robolectric: actionBar.hide() returns Null

懵懂的女人 提交于 2019-12-11 12:38:59
问题 I'm new to Android unit testing and I'm using Robolectric as a testing framework. I use Robolectric 2.2. I'm trying to test an activity which is like that : public class LoginActivity extends SherlockActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); ActionBar abs = getSupportActionBar(); abs.hide(); } and here's my test class : @RunWith(RobolectricTestRunner.class) public class LoginActivityTest

Could not find any version that matches org.robolectric:robolectric:2.3.+

不想你离开。 提交于 2019-12-11 12:07:49
问题 When syncing my Gradle project in Android Studio, I get the following error: Error:Could not find any version that matches org.robolectric:robolectric:2.3.+. Required by: gradle:android:unspecified I assume I am missing a repository in my build.gradle file. I'm new to Gradle and Maven, so I'm not sure what I should put. Any suggestions? Here are my build.gradle files: Project: buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.12.+'

Is there a way to execute a single Robolectric 2.3 test (using Gradle)?

亡梦爱人 提交于 2019-12-11 11:15:43
问题 I'm using Robolectric 2.3 and execute my unit tests with ./gradlew testDebug Is there a way to execute a single test or a single test class? 回答1: I'm running them in Android Studio and from there you can execute one test, one test case, all tests in the package: How to run unit tests with Android Studio About command line you can take a look on this plugin: https://github.com/JCAndKSolutions/android-unit-test 来源: https://stackoverflow.com/questions/24329875/is-there-a-way-to-execute-a-single

Robolectric Issue with ProgressBar

非 Y 不嫁゛ 提交于 2019-12-11 10:55:27
问题 I keep getting a RuntimeException from Robolectric when it tries to invoke an onCreate for an activity that has a ProgressBar. I've localized the issue to this block in the layout xml file. As soon as I remove this and re-run the test, things work fine. <ProgressBar android:id="@+android:id/progress_large" style="?android:attr/progressBarStyleLarge" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:visibility="invisible"/>

Android Testing Splash Screen

天大地大妈咪最大 提交于 2019-12-11 10:42:55
问题 So I have this Splash screen which is working well, but I would like to test "is the handler has lunched the next activity". class: public class SplashActivity extends Activity { private final int SPLASH_DISPLAY_LENGTH = 3000; private TextView quote_text; private int[] quote_id = {R.string.quote_1, R.string.quote_2, R.string.quote_3, R.string.quote_4, R.string.quote_5}; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout

Robolectric + Mockito

杀马特。学长 韩版系。学妹 提交于 2019-12-11 09:56:19
问题 Trying to build android unit tests using Robolectric. Everytime I need to mock a method that belongs to my project it becomes slightly heavy to create a Shadow class. I think using Mockito in such cases would be much easier and lighter. But when I try to use Mockito methods I get an error java.lang.IllegalArgumentException: dexcache == null (and no default could be found; consider setting the 'dexmaker.dexcache' system property) In order to fix this I believe the dexcache property needs to be

Exclude Test files from final build of android app

…衆ロ難τιáo~ 提交于 2019-12-11 09:29:19
问题 I am a newbie to android. I am using Robolectric to write unit tests for my android app. I am struggling to exclude the Test folder that I have created in the actual application from being included in the final apk or before releasing it to playstore. I have looked in Robolectric documents but I didn't come across any step that speaks about this. Any help or guidance is much appreciated. Thanks. 来源: https://stackoverflow.com/questions/23049782/exclude-test-files-from-final-build-of-android

RobolectricTestRunner's HelperTestRunner having trouble invoking Jmockit?

谁都会走 提交于 2019-12-11 08:33:46
问题 I'm having problems running tests in IntelliJ using Robolectric and it looks like jMockit might be a factor. My test itself has absolutely no jmockit and in fact the test is now just comparing two strings. I'm working with a large codebase that relies pretty heavily on jmockit, so I think there's an issue with the classpath having jmockit. (I saw something similar but not the same at can jmockit and robolectric coexist?) Is there a way to work around this? Am I going to have to blow away all

Robolectric: “AndroidManifest.xml not found” and “Unable to find resource ID #0x7f09001b”

寵の児 提交于 2019-12-11 07:29:54
问题 I'm running some tests with Roboletric, but I came across a issue that I can't solve. When I run the test, the following error appears with the "AndroidManifest": WARNING: No manifest file found at .\AndroidManifest.xml. Falling back to the Android OS resources only. To remove this warning, annotate your test class with @Config(manifest=Config.NONE). No such manifest file: .\AndroidManifest.xml I've tried these solutions that failed : @Config (manifest = Config.DEFAULT_MANIFEST_NAME) @Config

Robolectric + SQLiteStatement.executeUpdateDelete() doesn't perform any action

删除回忆录丶 提交于 2019-12-11 07:27:15
问题 I'm need to increment some integer in table. Instead of making select and consecutive update, i'm want to do this by single query. But out of luck. Following code returns 0: final SQLiteStatement stmt = helper.getWritableDatabase(). compileStatement("update my_table set my_count = my_count + 1 where _id = ?"); try { stmt.bindLong(1, id); return stmt.executeUpdateDelete(); } finally { stmt.close(); } And, of course, no record is updated. But this returns 1: final ContentValues v = new