Apply @Config annotation to TestClass hierarchy. #1596
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change applies @config annotations for a test classes entire hierarchy. This is very useful for putting @RunsWith and @config settings in a parent test class and extending the parent for individual tests classes.
My company's projects currently extend RobolectricTestRunner and overload the getConfig method to add this functionality allowing for a common place for our @RunsWith and @config annotations. We find that > 80% of the time we don't override them in the base test classes.
NOTE: This change could possibly break existing Robolectric tests IFF there exists a hierarchy and a parent of a test class has an @config annotation which is currently being ignored. Seems like this would only happen if someone extended an actual test class with @test annotated methods which seems rare. For this reason, this doesn't seem like a good change for a bug fix release. It's probably a good candidate for 3.0 or a 2.x release.