getActionBar() works fine on devices/simulator but returns null in testcases
问题 Application supports minSdk=14 and have ActionBar on every Activity . Application works fine since a long time and shows ActionBar on every Activity . Now I am writing Android JUnit Testcases but it gives NullPointException on line getActionBar().setDisplayHomeAsUpEnabled(true); The bottom line is getActionBar() works on devices but returns null during test cases. If I remove the line then testcases are fine. Here's how activity looks like. protected void onCreate(Bundle savedInstanceState) {