TestParameterInjector icon indicating copy to clipboard operation
TestParameterInjector copied to clipboard

Integrate with RobolectricTestRunner

Open AlanChiou opened this issue 4 years ago • 4 comments

If we test an Android component(Activity, Fragment, Service...) with Robolectric, we will use RobolectricTestRunner as the test runner.

And a test class only have a test runner. I also find a way to run a test class within multiple test runners, but I have no idea if it works with TestParameterInjector. https://bekce.github.io/junit-multiple-runwith-dependent-tests/

Could you have a look about this topic? Is possible that using TestParameterInjector as a Rule?

AlanChiou avatar Apr 23 '21 23:04 AlanChiou

Is possible that using TestParameterInjector as a Rule?

AFAIK, that's not possible in JUnit4, unfortunately. The only solution I think is to make a test runner that combines RobolectricTestRunner and TestParameterInjector or modify RobolectricTestRunner to support TestParameterInjector annotations.

We have an internal feature request to do this second option (RobolectricTestRunner to support the TestParameterInjector annotations). However, I'm being told this might either be a lot of work or practically impossible. I'll update this thread if we make any progress here.

nymanjens avatar Apr 24 '21 12:04 nymanjens