Reputation: 1007
I need a generic activity object to test another class.
Upvotes: 1
Views: 97
Reputation: 8641
It's hard to get a handle to an Activity other than the activity under test in a unit test based on ActivityInstrumentationTestCase2.
However, as the other respondent said, it's not a great idea to make a class dependent on a fundamental Android component like Activity. What's the use case?
Upvotes: 1
Reputation: 47759
Just make a mock ... inherit from Activity, and override whatever you need to override.
better yet, decouple the other class so that you don't have such a dependency on a framework class like Activity.
Upvotes: 1