title: How to set Unit Test to Fragment in Android
body: <p>I want to unit test an Android Fragment class.</p>
  
  <p>Can I set up a test using AndroidTestCase or do I need to use ApplicationTestCase?</p>
  
  <p>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.</p>
  
  <p>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!</p>
  
  <p>As I understand it, a Fragment has to live within an Activity. So could I create a mock Activity, or get the Application or Context to provide an Activity within which I can test my Fragment?</p>
  
  <p>Do I need to create my own Activity and then use ActivityUnitTestCase?</p>