Wednesday, May 15, 2019

The Robolectric JUnit runner doesn't support @ClassRule

I noticed yesterday that JUnit test suites run under Robolectric using @RunWith(RobolectricTestRunner.class) do not execute rules annotated with @ClassRule. I was hoping to allow some functionality to be packaged up into a rule so I could cleanly use it in many projects, but Robolectric just doesn't support class rules yet. Instead I'm creating an abstract class with @BeforeClass and @AfterClass methods, then making test suite classes inherit from that.

No comments:

Post a Comment