robolectric

Where is log output written to when using Robolectric + Roboguice?

佐手、 提交于 2019-12-02 18:43:36
I'm using Robolectric to test Android. I'm running my tests via maven, e.g. mvn -Dtest=LogTest test If I have code that writes to the logs, such as Log.d("TAG", "blah"); or using Roboguice's Ln Ln.d("blah"); I don't see any output in maven's surefire logs (text files). Ideally, I actually want simple log statements to go to the console. I can write to the console by using System.out.println("blah") , but of course I'd rather use the supported logging APIs. So my question is, why am I not seeing log output at all, and how can I get the log messages written to the console? I am running

Unable to locate a Java Runtime Android Studio Robolectric

丶灬走出姿态 提交于 2019-12-02 18:34:00
I've added Robolectric to an Android project. I'm using Android Studio with Build Tools in 19.0.1. I can run the tests with: $./gradlew test Which execute fine. If I try: $ gradle installDebug It executes fine as well: $ ./gradlew installDebug WARNING: Dependency commons-logging:commons-logging:1.1.1 is ignored for debugTest as it may be conflicting with the internal version provided by Android. In case of problem, please repackage it with jarjar to change the class packages WARNING: Dependency org.apache.httpcomponents:httpclient:4.0.3 is ignored for debugTest as it may be conflicting with

Adding Support Library to Robolectric 2.3

亡梦爱人 提交于 2019-12-02 17:51:04
问题 After inspiration from this template, I was able to get roblolectric and espresso tests working with android and gradle. The key was to store robolectric in it's own module. However, I 'm unable to add the support library to robolectric. How can I do that? Here's the gradle file of the robolectric module: apply plugin: 'java' // * What went wrong: // Execution failed for task ':robolectric-tests:test'. // > superClassName is empty! tasks.withType(Test) { scanForTestClasses = false include "**

Testing ViewPager (and CursorLoader) with Robolectric

爷,独闯天下 提交于 2019-12-02 16:54:29
Does anyone know how to test the following setup using Robolectric? Fragment containing a ViewPager, data loaded with a CursorLoader. With the code below, the CursorLoader is never pushed into the adapter for the view pager. I get stuck at the await() call. EventsFragmentTest.java: @RunWith(CustomRobolectricTestRunner.class) public class EventsFragmentTest extends AbstractDbAndUiDriver { // which element in the view pager we are testing private static final int TEST_INDEX = 0; protected SherlockFragmentActivity mActivity; protected EventsFragment_ mFragment; @Override @Before public void setUp

Android unit test case automation: Robolectric library vs Android Testing framework

。_饼干妹妹 提交于 2019-12-02 16:43:07
Wondering which one is the better choice to write unit test cases for android apps and libraries: Using Robolectric library or sticking with Android Testing framework. I want to run test suite at commandline and want it be independent of need of configuring emulator or letting a device attached with build machine. Does anyone of you run a comparative analysis on both of these or something better? Your experiences will be great help me to decide on the better solution. I use a tiered system, where I prefer earlier tiers where possible: Pure unit tests. I try to make as much code as possible

Android Unit Test with Retrofit2 and Mockito or Robolectric

故事扮演 提交于 2019-12-02 14:09:49
Can I test real response from retrofit2beta4? Do i need Mockito or Robolectic? I don't have activities in my project, it will be a library and I need to test is server responding correctly. Now I have such code and stuck... @Mock ApiManager apiManager; @Captor private ArgumentCaptor<ApiCallback<Void>> cb; @Before public void setUp() throws Exception { apiManager = ApiManager.getInstance(); MockitoAnnotations.initMocks(this); } @Test public void test_login() { Mockito.verify(apiManager) .loginUser(Mockito.eq(login), Mockito.eq(pass), cb.capture()); // cb.getValue(); // assertEquals(cb.getValue(

Adding Support Library to Robolectric 2.3

邮差的信 提交于 2019-12-02 11:43:05
After inspiration from this template , I was able to get roblolectric and espresso tests working with android and gradle. The key was to store robolectric in it's own module. However, I 'm unable to add the support library to robolectric. How can I do that? Here's the gradle file of the robolectric module: apply plugin: 'java' // * What went wrong: // Execution failed for task ':robolectric-tests:test'. // > superClassName is empty! tasks.withType(Test) { scanForTestClasses = false include "**/*Test.class" } dependencies { def androidModule = project(':App') compile androidModule testCompile

Android Testing with Robolectric and Dagger

老子叫甜甜 提交于 2019-12-02 08:14:49
I am trying to write an Android application using Dagger. Trying to follow the TDD approach, I started writing a test for my First activity. For writing tests I am using Robolectric and I am trying to make it work in different scenarios using Mockito. Short story: I have an android activity which I want to test using robolectric. This activity has some of its dependencies provided through Dagger. I managed to make this work by overriding the Application class and providing a mock of the utility class. What I need now is to be able to change the behavior of the utility class(using Mockito) in

Robolectric with ActiveAndroid setup nullpointerexception on ActiveAndroid$ReflectionUtils

我的未来我决定 提交于 2019-12-02 06:00:28
问题 I am trying to implement robolectric testing in an existing app. I can run simple static tests but when I add testing with ActiveAndroid I get NullPointerExceptions, I think ActiveAndroid can not be found when the unit test is being run. Im not sure maybe there are some configurations for ActiveAndroid for Robelectric unit testing. Kindly help me on this one. This is the project structure: MainApp -src/main -src/test LibraryApp -src/main/models <--- here are my models and classes for active

Impossible RuntimeException: Stub with Robolectric

纵然是瞬间 提交于 2019-12-02 04:52:54
问题 I've spent hours trying to figure this out. I'm using Maven to build and test a project in IntelliJ IDEA with Robolectric. I have Robolectric declared before Android in the POM, and I've used the SDK deployer to install to my local repo. But I still keep getting this error: java.lang.RuntimeException: Stub! at android.net.Uri.$$robo$$Uri_30fc_parse(Uri.java:53) at org.robolectric.bytecode.ShadowWrangler$InvocationPlan.callOriginal(ShadowWrangler.java:591) at android.net.Uri.parse(Uri.java) at