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

How would one work with subcomponents? #74

Open
marius-bardan opened this issue Apr 25, 2018 · 1 comment
Open

How would one work with subcomponents? #74

marius-bardan opened this issue Apr 25, 2018 · 1 comment

Comments

@marius-bardan
Copy link

marius-bardan commented Apr 25, 2018

Let's say I have an AppComponent, which has a subcomponent UserComponent, which in turn has a ProfileComponent, each with sub/modules:

@AppScope
@Component(modules={AppModule.class, NetworkModule.class})
interface AppComponent {
  UserComponent userComponent(...);
}

@UserScope
@Subcomponent(modules={UserDataModule.class})
interface UserComponent {
  ProfileComponent profileComponent(...);
}

@UserProfileScope
@Subcomponent(modules={SomeProfileModule.class})
interface ProfileComponent {
  // other subcomponents here
  void inject(UserProfileActivity activity);
}

What I'd like is to have an integration test, from the UserProfileActivity onwards.
From the examples I'm seeing, they only show how to deal with 1 component or top-level component.

How would I get a reference in this case, to the ProfileComponent, since creating a Rule for it will not cut it, since it has to be created like: appComponent.userComponent(...).profileComponent(...)?

Thinking it has something to do with addComponentDependency, but unsure how it should work when I have a module (e.g. UserDataModule) with an activity reference in the middle.

@fabioCollini
Copy link
Owner

Hi, I have some questions to understand better your problem:

  • what test are you trying to write? An Espresso test that launch the UserProfileActivity?
  • which objects do you wan to to replace with some mocks in the test? Which component are defined in?
  • do you get an error if you don't use addComponentDependency in a test?

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

2 participants