activityunittestcase

Unit Test an Android Fragment

可紊 提交于 2019-11-29 21:19:49
I want to unit test an Android Fragment class. Can I set up a test using AndroidTestCase or do I need to use ApplicationTestCase? Are there any useful examples of how these two TestCases can be used? The testing examples on the developer site are minimal and just seem to focus on testing Activities. All I've found elsewhere are examples where the AndroidTestCase class is extended but then all that's tested is adding two numbers together or if the Context is used, it just does a simple get and tests that something is not null! As I understand it, a Fragment has to live within an Activity. So