Skip to content
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 examples to use ActivityController#close #115

Merged
merged 2 commits into from Jul 31, 2022

Conversation

seadowg
Copy link
Collaborator

@seadowg seadowg commented May 27, 2022

Closes robolectric/robolectric#7041

As discussed in the issue, the examples needed to be updated so that it's clear that close() should be called. We could also add a note to Best Practices around this, but I wanted to start with making sure the code examples are up to date.

* Use `Robolectric.buildActivity`/`ActivityController#setup` with `try-with-resources` to demonstrate test needing to call `ActivityController#close`
* Replace AssertJ(?) assertion with basic JUnit `assertEquals`
* Use `findViewById` rather than public view fields
Copy link
Member

@utzcoz utzcoz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks.

@utzcoz utzcoz requested a review from hoisie May 27, 2022 14:10
@utzcoz
Copy link
Member

utzcoz commented May 31, 2022

Hi @hoisie , could you help to review this PR? Thanks.

@utzcoz
Copy link
Member

utzcoz commented Jul 30, 2022

Hi @hoisie , could you help to review this PR? IMO, it can provide more precise usage of ActivityController.

@utzcoz utzcoz merged commit 76f2f18 into robolectric:master Jul 31, 2022
@utzcoz
Copy link
Member

utzcoz commented Jul 31, 2022

@seadowg Could you help to update example in Robolectric main repository README?

@seadowg
Copy link
Collaborator Author

seadowg commented Jul 31, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Does ActivityController#close() need to be called to prevent leaks?
3 participants