Reputation: 3340
Here's my service test code.
public class BackgroundTaskServiceTest extends ServiceTestCase<BackgroundTaskService> {
public BackgroundTaskServiceTest(Class<BackgroundTaskService> serviceClass) {
super(serviceClass);
}
public BackgroundTaskServiceTest() {
super(BackgroundTaskService.class);
}
@SmallTest
public void startServiceTest() {
assertEquals(0, 1);
}
@Override
public void setUp() {
try {
super.setUp();
System.err.println("setup called");
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void tearDown() {
try {
System.err.println("teardown called");
super.tearDown();
} catch (Exception e) {
e.printStackTrace();
}
}
}
I right-click the project name and select "Run as Android Junit Test". The setUp
and tearDown
callbacks are called properly , but my startServiceTest
is never run.
This is the screen shot of test results:
And another strange thing is that the "setup called" and "teardown called" both appear twice.
So anyone knows why? Thanks.
Upvotes: 0
Views: 123
Reputation: 6219
I think the way that the ADT plugin for Android JUnit works, you need to name your tests starting with 'test', e.g.:
public void testStartService() {
assertEquals(0, 1);
}
Try that and see if it runs.
Upvotes: 1