-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update the "Shadows" page #311
Conversation
This PR updates the [Shadows](https://robolectric.org/extending/) page. This continues the work I've done on other pages: - Adding Kotlin code samples. - Adding links to other Robolectric pages and the Android documentation. - Removing outdated sections.
1. Android native code cannot execute on your development machine. | ||
2. There are no Android system services running on your development machine. | ||
3. Android includes next to no APIs suitable for testing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've removed the leading texts since they didn't seem to bring any value.
|
||
### Using a Custom Shadows | ||
|
||
Custom Shadows get hooked up to Robolectric using the `@Config` annotation on the test class or test method, using the `shadows` array attribute. To use the `MyShadowBitmap` class mentioned in the previous section, you would annotate the test in question with `@Config(shadows={MyShadowBitmap.class})`, and to include multiple custom shadows: `@Config(shadows={MyShadowBitmap.class, MyOtherCustomShadow.class})`. This causes Robolectric to recognize and use your custom shadow when executing code against the class you shadowed. | ||
Custom Shadows get hooked up to Robolectric using the [`@Config`](javadoc/latest/org/robolectric/annotation/Config.html) annotation on the test class or test method, using the [`shadows`](javadoc/latest/org/robolectric/annotation/Config.html#shadows()) array attribute. To use the `MyShadowBitmap` class mentioned in the previous section, you would annotate the test in question with `@Config(shadows = { MyShadowBitmap.class })`. This causes Robolectric to recognize and use your custom shadow when executing code against the class you shadowed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've removed the example with multiple custom shadows, as it teaches more about Java syntax rather than Robolectric usage.
### Don't use `useinheritImplementationMethods` | ||
This is usually unnecessary and will be removed in [Robolectric 3.8](https://github.com/robolectric/robolectric/releases/tag/robolectric-3.8) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
useinheritImplementationMethods
doesn't seem to exist anymore (as documented), and Robolectric 3.8 is a rather old version now. So I've removed that section.
This PR updates the Shadows page.
This continues the work I've done on other pages: