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

Wrap the code that mocks the camera with a try-catch clause in the readme #375

Merged
merged 5 commits into from
Jul 5, 2021

Conversation

rocboronat
Copy link
Member

It happened to me that the code that performs something with the camera crashes, so the release is never called, so the next test fails because the init has been called twice without releasing it.

Totally open for discussion, of course! But as it's a piece of code that we're aiming people to copy-paste...

@alorma
Copy link
Member

alorma commented Oct 15, 2020

Wondering...

Maybe we can create a helper function, that does that?

Wrap code in a try catch and has a lambda to allow any needed interactions

@Sloy
Copy link
Member

Sloy commented Oct 15, 2020

I think the best / right approach is to do Intents.init() and Intents.release() in the @Before and @After in the test, and let JUnit handle it.

@rocboronat
Copy link
Member Author

What do you think about doing it in the Barista rule, @Sloy?

@Sloy
Copy link
Member

Sloy commented Oct 23, 2020

Dunno. That's actually what the IntentsTestRule does. Taking a quick look at the code, I don't see anything that could break. I don't know if there's any performance impact though.

But I don't really use the BaristaTestRule myself, so... go go go! 🥳

@Sloy
Copy link
Member

Sloy commented Oct 23, 2020

PS: We need to talk about BaristaTestRule, the Espresso's ActivityTestRule is now deprecated in favor of ActivityScenario.

@rocboronat
Copy link
Member Author

😱 🙀

@rocboronat
Copy link
Member Author

Hey team! Is that an LGFM? 🤩

@rocboronat
Copy link
Member Author

#402 relates to this.

@alorma alorma enabled auto-merge (squash) July 1, 2021 09:17
@rocboronat rocboronat changed the title Wrap the code that mocks the camera with a try-catch clause Wrap the code that mocks the camera with a try-catch clause in the readme Jul 5, 2021
@alorma alorma merged commit 18e7974 into master Jul 5, 2021
@alorma alorma deleted the try-catch-camera-mock branch July 5, 2021 12:19
@rocboronat
Copy link
Member Author

Thanks @alorma 😄

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.

3 participants