ServiceTestRule

A JUnit rule that provides a simplified mechanism to start and shutdown your service before
and after the duration of your test. It also guarantees that the service is successfully
connected when starting (or binding to) a service. The service can be started
(or bound) using one of the helper methods. It will automatically be stopped (or unbound) after
the test completes and any methods annotated with
After are
finished.

Intent: Identifies the service to connect to. The Intent may
specify either an explicit component name, or a logical
description (action, category, etc) to match an
IntentFilter published by a service.

connection

ServiceConnection: Receives information as the service is started and stopped.
This must be a valid ServiceConnection object; it must not be null.

Protected methods

afterService

void afterService ()

Override this method to do your own service specific clean up after the service is shutdown.
The method is called after each test method is executed including any method annotated with
After
and after necessary calls to stop (or unbind) the service under test were called.

beforeService

void beforeService ()

Override this method to do your own service specific initialization before starting or
binding to the service. The method is called before each test method is executed including
any method annotated with
Before.
Do not start or bind to a service from here!