robolectric/robolectric — pull request #1081 by kriegfrj (2014-05-15 11:26:30+00:00)
Title: org.robolectric.util.ServiceController

Dear Robolectric team,

I am fairly new to Robolectric and this is my first ever GitHub pull request - please be gentle! :)

This commit basically adds org.robolectric.util.ServiceController to parallel ActivityController for services. I was trying to do things in my Service implementation (like calling getSystemService()) that required the Service's ContextBase to be initialised, or else a NullPointerException is thrown. This is achieved using the ServiceController and calling attach(). I have also added support for other lifecycle methods.