'Parameterize some tests but not others with RobolectricTest
I am looking to add a parameterized test to an existing test suite that uses the Robolectric test framework, like so:
@RunWith(RobolectricTestRunner.class)
public class SomeTest {
/* ... Tons of tests */
}
One of the tests is for functionality that used to be fixed but now takes a parameter. This answer suggests that in order to run just the one test in a parameterized fashion, I should add @RunWith(Enclosed.class)
, then wrap the test I want to parameterize in its own class. Unfortunately, it seems that I must choose either Enclosed.class
or RobolectricTestRunner.class
, not both.
There seems to be an open issue on robolectric
related to this, but the answer in the issue seems to be to wrap the whole test in @RunWith(Enclosed.class)
, then wrap the inner tests in a class with @RunWith(RobolectricTestRunner.class)
. Given that I'm only changing one test in a fairly large set of test cases, I'm not amazingly comfortable with the idea of refactoring everything to be in a set of inner classes.
Is there any way to get the Robolectric test runner to parameterize one test from a larger suite?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|