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

Hilt Testing and E2E tests #4599

Open
franciscoaleixo opened this issue Jan 31, 2025 · 0 comments
Open

Hilt Testing and E2E tests #4599

franciscoaleixo opened this issue Jan 31, 2025 · 0 comments

Comments

@franciscoaleixo
Copy link

franciscoaleixo commented Jan 31, 2025

Our team would like to create E2E tests where the app should function as close to production as possible (even with backend). We realise this is inherently flaky but I'll leave that discussion for another day. We've figured we would use Hilt testing utils to inject some "interceptor-like" utils so that, for example, we could know what is coming from backend on our tests and check the corresponding behavior on our app.

Also, we'd like our test cases to be very self-contained, i.e. each test case should launch its own process / application, as we'd like to avoid sharing state across test cases and also avoid crashes in one test case spilling over to the rest. From what we've investigated, this seems to be possible with Android Test Orchestrator.

The issue now is that it doesn't seem like it is possible to accomplish this with @HiltAndroidTest. It looks like the application is always shared between test cases (even using Orchestrator) and the application is actually initialized before any test case. It is especially evident from the abundance of exceptions we've gotten trying to make this work (WorkManager/DataStore initializing twice as they are rebound each test case, etc.). We also realize this is expected and well documented.

Regardless, I guess my question is: is there any way to make Hilt testing work with Android Test Orchestrator and make these self-contained test cases possible?

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

No branches or pull requests

1 participant