如何使用Roboelectric测试IntentService-错误

时间:2018-08-23 01:50:34

标签: android unit-testing robolectric intentservice

我在下面收到一条错误消息,环顾四周,但是有一种解决方案可以解决。

How to test an IntentService with Robolectric?

  

java.lang.RuntimeException:java.lang.NoSuchMethodException:   tapme.data.service.AlarmService。(java.lang.String)

这是我实施的单元测试-

    @RunWith(RobolectricTestRunner.class)
    public class AlarmServiceUnitTest {

    private AlarmService service;
    private IntentServiceController<AlarmService> controller;

    @Before
    public void setup() {
        controller = Robolectric.buildIntentService(AlarmService.class).create();
        service = controller.create().get();
    }

    @Test
    public void alarmServiceShouldBeNotNull() {
        assertNotNull(service);
    }
}

0 个答案:

没有答案