Questions tagged [servicetestcase]

"This test case provides a framework in which you can test Service classes in a controlled environment. It provides basic support for the lifecycle of a Service, and hooks with which you can inject various dependencies and control the environment in which your Service is tested." http://developer.android.com/reference/android/test/ServiceTestCase.html

This test case provides a framework in which you can test Service classes in a controlled environment. It provides basic support for the lifecycle of a Service, and hooks with which you can inject various dependencies and control the environment in which your Service is tested.

Android Developer

32 questions
11
votes
5 answers

Android ServiceTestCase for IntentService

I'm currently writing unit tests for an android application and stumbled into the following issue: I use the ServiceTestCase to test an IntentService like this: @Override public void setUp() throws Exception { super.setUp(); } public void…
5
votes
2 answers

Can not get Android ServiceTestCase to run

I am unable to get any test cases that extend ServiceTestCase to run. There are no errors they are just not executed. Other test cases that extend AndroidTestCase do run. The projects are set up as follows: I have a Android Library that contains a…
lucasweb
  • 1,736
  • 5
  • 28
  • 42
5
votes
1 answer

Can Android's ServiceTestCase send Messages to my service?

I want to test my bound service with ServiceTestCase. The testing consists of binding to MyBindServer, and sending a Message. Watching the logs, you can see the service is started when onBind() is called, and a message is sent from testAHello(),…
David
  • 63
  • 1
  • 8
5
votes
1 answer

Instrumentation test cases for InputMethodService

I have extended the InputMethodService class to create my a custom IME. However, I am struggling to write valid Instrumentation test cases to verify the behavior. Previously the Service, could be tested using ServiceTestCase. But…
5
votes
2 answers

ServiceTestCase.getService?

I'm trying to build a valid junit testing suite on android. Since i'm new to Junit i can't figure out how to use the ServiceTestCase class. I can't figure it out how to get the getService() method working. it ever returns me null . So i decided to…
Andrea Baccega
  • 27,211
  • 13
  • 45
  • 46
4
votes
1 answer

MockContentResolver in a ServiceTestCase null pointers

I'm trying to create a Service in a TDD-ish manner and to that end I have created the following test. The service basically polls a Web Service and puts new information into a Content Provider. Since it is a service, I am using the Content Provider…
adam goucher
  • 1,936
  • 1
  • 11
  • 7
4
votes
0 answers

Android Service: Dependency injection?

I'm trying to unittest my Service through a ServiceTestCase, but try to do so without using Guice or RoboGuice (Because of Avoid dependency injection frameworks). I want to inject a dependency other than Application or Context, but can't get it…
4
votes
1 answer

How to test the autogenerated java file using JUnit for my AIDL

I am using eclipse for writing JUnit test case for my project. My project contains a bound service based on AIDL. After executing the project i get an autogenerated java file for the AIDL, in the gen folder. This file contains a Stub class which has…
Lord Nick
  • 582
  • 8
  • 29
3
votes
0 answers

Using PendingIntent in unit test to test a service

I've got a IntentService (actually a WakefulIntentService!) that returns result to requests (i.e., from activities) using a PendingIntent that is added to the intent used to start the service. Earlier I used ResultReceiver but found that it crashes…
3
votes
4 answers

AsyncTask.onPostExecute() never gets called in ServiceTestCase

I am writing a unit test for a service using ServiceTestCase. The service basically executes an AsyncTask that does some work and then does something else in onPostExecute(). The service works as expected when I run and debug it in a (virtual)…
3
votes
1 answer

How can I use a real Application object with Android's ServiceTestCase

I'm trying to test a service that requires a real Application object, not the MockApplication that the ServiceTestCase provides. How can I create a real Application object in my ServiceTestCase?
Dan Devine
  • 859
  • 1
  • 8
  • 19
2
votes
0 answers

Android Context in TestProject

I was trying to achieve automation testing scenario using JUnit Framework of android. I used CountDownLatch as I wanted to include one asyncronous scenario. I have written a testcase file using ServiceTestCase for my service. The service…
Shrikanth Kalluraya
  • 1,099
  • 1
  • 16
  • 34
2
votes
1 answer

How to write service test for UpdateAsync in Microsoft Graph API (Add multiple members to a group in a single request)

I am using Microsoft Graph Api client and performing add members to group. Docs here :- https://learn.microsoft.com/en-us/graph/api/group-post-members?view=graph-rest-1.0&tabs=csharp#example-2-add-multiple-members-to-a-group-in-a-single-request I…
2
votes
0 answers

getSystemContext() of my ServiceTestCase returns null

I have a test with the code below, but I get a NullpointerException because getSystemContext() returns null. My project looks as follows: ~/trunk/src// ~/trunk/test/ ~/trunk/
1
vote
3 answers

How to copy files from assets on setUp method from an android Junit ServiceTestCase?

I'm writing JUnit test code for an android service implementation, and I have to initialize the tests with some files copied on sdcard. My class signature is like this: public class ImageServiceTest extends ServiceTestCase I'm…
cassioso
  • 966
  • 1
  • 13
  • 27
1
2 3