Linked Questions

Popular Questions

Resetting between Robolectric tests

Asked by At

I have a suite of Robolectric tests for my Android application, all of which run green.

I'm adding a new test, around the behaviour of a fragment. When I add this test, related tests in another test class around a different fragment start failing.

Only test code has changed. This implies to me that there is some shared state between these two screens, I am happy to go and hunt that down and fix it. In the mean time however I'm trying to work out how to completely reset Robolectric between tests.

Is this possible? Can you clear down state held in the Application, statics/singletons and databases in Robolectric. I've tried Robolectric.reset() without much luck. I'm using Robolectric 3.0.

Related Questions