servicetestcase

MockContentResolver in a ServiceTestCase null pointers

痴心易碎 提交于 2019-12-22 08:37:38
问题 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 that it will be storing information into as the oracle of the test. I think what I want to do is create a MockContentResolver in order to achieve this but there is a lack of examples of it outside of a ProviderTestCase2 class. When I run this

Can not get Android ServiceTestCase to run

霸气de小男生 提交于 2019-12-07 06:35:09
问题 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 service. It's manifest file is as follows: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.something.android" android:versionCode="1" android:versionName="1.0"> <uses-sdk

Can not get Android ServiceTestCase to run

别说谁变了你拦得住时间么 提交于 2019-12-05 10:41:18
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 service. It's manifest file is as follows: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.something.android" android:versionCode="1" android:versionName="1.0"> <uses-sdk android:minSdkVersion="9"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

ServiceTestCase<T>.getService?

北城余情 提交于 2019-12-03 13:44:08
问题 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 start it via startService. It does not work. Could you please help me ? Thanks 回答1: This is what you need to test your service public class MyServiceTests extends ServiceTestCase<MyService> { private static final String TAG = "MyServiceTests";

Can Android's ServiceTestCase<MyService> send Messages to my service?

老子叫甜甜 提交于 2019-12-03 10:12:39
问题 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(), but, the server's handleMessage() is never called. From the logs: I/TestRunner( 2099): started: testAHello(com.inthinc.mybindserver.test.MyBindServerTest) I/MyBindServerTest( 2099): setUp() I/MyBindServer( 2099): onBind, action=com.inthinc

ServiceTestCase<T>.getService?

烂漫一生 提交于 2019-12-03 03:46:27
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 start it via startService. It does not work. Could you please help me ? Thanks This is what you need to test your service public class MyServiceTests extends ServiceTestCase<MyService> { private static final String TAG = "MyServiceTests"; public MyServiceTests() { super(MyService.class); } /** * Test basic startup/shutdown of Service */ @SmallTest

Android ServiceTestCase for IntentService

走远了吗. 提交于 2019-11-29 09:25:41
问题 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 testService() { Intent intent = new Intent(getSystemContext(), MyIntentService.class); super.startService(intent); assertNotNull(getService()); } However I noticed that my IntentService is created (means that onCreate is called) but I never receive a call