Inheritance Support
See original GitHub issueIf mocks and injections are repeated, I like to extract it to a base class. This way, I can repeat same dependencies for other tests without having to repeat. For example:
public abstract class ActivityTest {
@Rule
public final MyDaggerMockRule daggerMockRule = new MyDaggerMockRule();
@Mock
protected DependencyA mockDependencyA;
@Named("s1")
protected String s1 = "test_string_s1";
@Named("s2")
@InjectFromComponent
protected String s2;
}
@RunWith(AndroidJUnit4.class)
@LargeTest
public class AnActivityTest extends ActivityTest {
@Rule
public ActivityTestRule<AnActivity> activityTestRule =
new ActivityTestRule<>(AnActivity.class, true, false);
@Mock
DependencyB mockDependencyB;
@Named("s3")
@InjectFromComponent
protected String s3;
...
}
Is this supposed to work already? I noticed that we get main app dependencies instead of the ones from defined in the test, particularly in the base class.
PS: This library saves me a lot of headache. Thank you.
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Inheritance in Java - GeeksforGeeks
In Java, inheritance means creating new classes based on existing ones. ... Reusability: Inheritance supports the concept of “reusability”, ...
Read more >Inheritance (object-oriented programming) - Wikipedia
Inheritance allows programmers to create classes that are built upon existing classes, to specify a new implementation while maintaining the same behaviors ( ......
Read more >1.7: OOP Inheritance - Engineering LibreTexts
Reusability: Inheritance supports the concept of “reusability”, i.e. when we want to create a new class and there is already a class that ......
Read more >Inheritance in Object Oriented Programming - Analytics Vidhya
Python also supports various types of inheritance in OOPS which I will cover in detail in this article besides covering what is inheritance...
Read more >Multiple Inheritance
Multiple Inheritance. C++ allows a special kind of inheritance known as multiple inheritance. While most object oriented languages support inheritance, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

You are right, I added the support for
@InjectFromComponentannotated fields in base class in commitfe0c164dad. I’ll release a new version soon. Thanks again for your reportWorks fine…