How to inject a dependency when testing an Android activity without a third-party framework?
- 阅读更多 关于 How to inject a dependency when testing an Android activity without a third-party framework?
问题 I want to test an Android activity CommentActivity that normally constructs and uses an instance of CommentsDataSource (both are classes that I wrote). public class CommentActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { : CommentsDataSource = new CommentsDataSource(..); : } : } I'm willing to create MockCommentsDataSource myself and would like to avoid using a third-party mocking framework. (Why? Because I'm a teaching trying to reduce the amount of