Questions tagged [robolectric]

Robolectric is a unit testing framework that allows Android applications to be tested on the JVM in seconds without using an emulator or device.

Robolectric allows to run Android tests inside the JVM on your workstation. Running tests on an Android emulator or device is often slow. Building, deploying, and launching the app often takes a minute or more.

Robolectric is open sourced under MIT license.

Project website: robolectric.org

1684 questions
0
votes
1 answer

Unit test private methods in roboletric android

Unit testing private methods may not be good practise but few methods in product has complex login in private methods. Can we somehow reflect or call private methods in roboletric in android OR any library similar to roboletric which helps in…
KOTIOS
  • 11,177
  • 3
  • 39
  • 66
0
votes
1 answer

ContentProvider test using Robolectric

I created a custom ContentProvider, which implemented by Sqlite query, update, insert etc. And in my code, I used this ContentProvider to store my datas. Now I want to use Robolectric to unit test my app. But the test code will fail as…
RickSu
  • 1
  • 2
0
votes
1 answer

java.lang.IllegalArgumentException: App ID length must be 32 characters

Facing issue when i try to run the JUnit test class java.lang.RuntimeException: java.lang.IllegalArgumentException: App ID length must be 32 characters. at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:244) at…
Vivek Singh
  • 1,201
  • 3
  • 17
  • 39
0
votes
2 answers

Mocking getActionBar() returns null

I'm testing an activity, and I want to mock getActionBar(). I've tried doing it the usual way, that is ActionBar mActionBar; @Before public void setup() { initMocks(this); mActionBar = Mockito.mock(ActionBar.class); } @Test public…
stack
  • 225
  • 4
  • 12
0
votes
0 answers

Can't find test application with Robolectric

Using Robolectric 3.3.1. Having issues setting the application to my custom test application. @RunWith(RobolectricTestRunner.class) @Config(constants = BuildConfig.class, sdk = 23, application = UnitTestApplication.class) public class SomeTest…
J. Ho
  • 51
  • 4
0
votes
1 answer

Android gradle exclude module not working

I've trying to remove a module from a dependency: accessibility-test-framework org.robolectric:robolectric:3.2.2 uses…
Killesk
  • 2,734
  • 3
  • 22
  • 29
0
votes
1 answer

How to compare two intent using assertj-android

Hi I am using roboelectric for unit testing of my android application. I want to compare expected intent and actual intent using assertj-android. I have added required dependency of assertj-android, even though I have done Gradle sync multiple times…
N Sharma
  • 33,489
  • 95
  • 256
  • 444
0
votes
1 answer

Android Integration tests without emulator

I am wondering if there is an option to test client library which uses Android (mock) and calls backend running on some endpoint? The use case could be: Have a library called 'A' that requires android's context (extracts data from it) and Google…
Zis
  • 162
  • 16
0
votes
0 answers

Robolectric testing asynctask

I'm testing my app with Robolectric, but whenever there is an asynctask the execution flow continue without waiting for it, after some research I found this method flushBackgroundThreadScheduler() that execute all runnables that have been queued on…
Abdennacer Lachiheb
  • 4,388
  • 7
  • 30
  • 61
0
votes
0 answers

Rebolectric: DividerItemDecoration blocks setting measurement to recyclerview

I am writing test cases for RecyclerView items using Robolectric. Facing NullPointerException while calling recyclerView.measure(0,0) because RecyclerView have applied with RecyclerView.ItemDecoration and it is working fine for the RecyclerView…
SathishKumar
  • 1,644
  • 1
  • 14
  • 28
0
votes
1 answer

Class.getResourceAsStream in Robolectric environment fails to return correct stream in M platform

I've got a problem with switching to M platform in robolectric runner. Class.getResourceAsStream seems to perform differently when using Build.VERSION_CODES.M and Build.VERSION_CODES.LOLLIPOP_MR1 My application uses PhoneUtils library that loads its…
Motorro
  • 227
  • 2
  • 10
0
votes
1 answer

Android JUnit run both Espresso and Robolectric test suites

for a specific project we need to run both Espresso and Robolectric test suites but it seems that their dependencies seem to clash very badly. Therefore my question, is it even possible to have them both or should we settle for another solution? Our…
qantik
  • 1,067
  • 1
  • 10
  • 20
0
votes
1 answer

Fail to run test with AndroidAnnotation, Robolectric and PowerMock

I am new to unit test and I am trying to use robolectric to do the test for my android app, but I encountered some problems DemoPresenterTest @RunWith(RobolectricTestRunner.class) @Config(constants = BuildConfig.class, sdk = 23) @PowerMockIgnore({…
Kenny
  • 3
  • 1
0
votes
1 answer

Robolectric No shadows modules found containing a org.robolectric.ShadowsAdapter

I followed official tutorial to add robolectric to my existing android application. But when i'am trying to run a simple test i got an error: java.lang.RuntimeException: No shadows modules found containing a org.robolectric.ShadowsAdapter at…
Ilya Kirillov
  • 29
  • 1
  • 6
0
votes
0 answers

Inflate exception when trying to inflate custom layout with Iconify using Robolectric RuntimeEnvironment

I have this layout test, in my layout menu_item_layout.xml there is an IconTextView with text "{fa-times}". When I try to run the test I get android.view.InflateException. But if I remove the text "{fa-times}" from IconTextView, the test passed…
wint
  • 1,266
  • 2
  • 14
  • 28
1 2 3
99
100