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

Use FakeInitModule in tests when possible #649

Conversation

bidetofevil
Copy link
Collaborator

@bidetofevil bidetofevil commented Apr 2, 2024

Goal

Tweak tests so InitModule won't have to be used if not necessary. It will require some Android stuff now later so test that don't use the right test runner will puke when trying to instantiate the Embrace class.

The next PR will take care of this, but lets just do this so it won't actually be necessary.

Testing

Only tests are changed

Copy link
Collaborator Author

bidetofevil commented Apr 2, 2024

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @bidetofevil and the rest of your teammates on Graphite Graphite

Copy link
Contributor

@fractalwrench fractalwrench left a comment

Choose a reason for hiding this comment

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

Change looks good if it's what we want to do, but I want to understand why using InitModule is a bad thing before merging this.

Base automatically changed from hho/embrace-fixed-attribute to master April 3, 2024 15:32
Copy link
Collaborator Author

It's not a bad thing necessarily. I made this change because in a later PR, we will be creating a new SystemInfo with default values every time an EmbraceImpl instance is generated (as part of InitModuleImpl). The defaults require accessing the BUILD properties, some of which aren't available unless you use the Android/Robolectric test runner.

This change made it so that we initialize don't do that, instead initializing a fake where the SystemInfo attributes are replaced that don't need access to BUILD.

But it turns out that this alone won't fix all the tests, so I ended up try-catching all the problematic BUILD accesses, but decided to keep this as well to follow the existing pattern of using fakes.

I can take or leave this tbh. I don't think it's required anymore, but since the other tests all use fakes, perhaps this makes sense too?

@bidetofevil bidetofevil changed the base branch from master to hho/consolidate-build-object-usage April 3, 2024 15:48
Copy link
Collaborator Author

Chatted with Jamie off line. Will abandon this change as the real thing is preferred, and this shouldn't be necessary anymore.

@bidetofevil bidetofevil closed this Apr 3, 2024
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.

None yet

2 participants