• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Is there another android unit testing framework

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From what I've read, it is possible for Robolectricto intercept the Http Requests that the application in testing does. So I initially planned to capture these Http Requests and then modify their values by intercepting the http responses through another Robolectric method .setDefaultHttpResponse. The problem is, I am using Robotium already in the app and I need these integration tests and Robolectric does not run on android devices mainly because of this Log I received :



I really needed Robolectric's feature to capture outgoing http requests. That is the only thing I need from it. So knowing that it will not go well with my current implementation of my test cases and how I need them, I am kind of lost how else I am going to test them. My app has different architecture that is quite not unit test ready and I can't modify it's code. It sends HttpRequests on it's onCreate method and it will then modify the layout depending on what the http response is.

Are there any frameworks that could do this that would go well with robotium integration tests?
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Roboelectric looks like it is not supposed to be running on the emulator/phone... its purpose is so you can unit test the application in a normal Java environment without having to go to the phone. So the fact that you are trying to run it on the phone is using the framework incorrectly.

So you have two solutions: 1) use Roboelectric on the desktop the way it is supposed to run or 2) use a mocking framework to get the tests to run on the device the way you want. I think Mockito would work with either framework for running HTTP request (Apache HtttpClient or HttpURLConnection).
 
Steve Luke
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Two things I forgot:

1) Welcome to the Ranch!

2)

John Johner wrote:It sends HttpRequests on it's onCreate method and it will then modify the layout depending on what the http response is.


I hope you are not calling the HttpRequest on the same thread as onCreate/the UI! This will lead to poor responsiveness and possible a warning to your users that the application has hung when the data connection is slow. What you should be doing is displaying some default UI components immediately and starting an AsyncTask which does the web communication, then feeds the changes that need to be made back to the UI thread so Android doesn't think your app is frozen.
 
John Johner
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Steve Luke wrote:Two things I forgot:

1) Welcome to the Ranch!

2)

John Johner wrote:It sends HttpRequests on it's onCreate method and it will then modify the layout depending on what the http response is.


I hope you are not calling the HttpRequest on the same thread as onCreate/the UI! This will lead to poor responsiveness and possible a warning to your users that the application has hung when the data connection is slow. What you should be doing is displaying some default UI components immediately and starting an AsyncTask which does the web communication, then feeds the changes that need to be made back to the UI thread so Android doesn't think your app is frozen.



Yes I am using another thread to do the HttpRequest. If it wouldn't be too much, may I ask for a link on how I can use Mockito to catch http requests/responses from our server?
 
Oh sure, it's a tiny ad, but under the right circumstances, it gets bigger.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic