activityunittestcase

Getting Instrumentation run failed due to 'java.lang.NullPointerException'

£可爱£侵袭症+ 提交于 2019-12-23 07:08:28
问题 I am trying to write Unit test cases for Activities in my app by extending the test class with ActivityUnitTestCase . I could successfully run the test cases earlier but now I'm always getting the exception while running them. Even though I'm pretty familiar with handling NullPointerExceptions , I couldn't figure out the problem that's causing this. I couldn't find any similar questions so I'm posting this one. Stack trace shows me there is a null object reference at this line in my code

Android Unit Tests with AppCompat project library

自闭症网瘾萝莉.ら 提交于 2019-12-22 17:12:33
问题 I have a project with some unit tests that extends ActivityUnitTestCase, but when I installed the android-support-v7-appcomapt project library to use the ActionBar, these tests have stopped working. I also have some ActivityInstrumentationTestCase2 tests and they are working fine. This is my setup protected void setUp() throws Exception { super.setUp(); Intent intent = new Intent(getInstrumentation().getTargetContext(), MyActivity.class); startActivity(intent, null, null); // The exception

Android Unit Tests with AppCompat project library

可紊 提交于 2019-12-22 17:12:12
问题 I have a project with some unit tests that extends ActivityUnitTestCase, but when I installed the android-support-v7-appcomapt project library to use the ActionBar, these tests have stopped working. I also have some ActivityInstrumentationTestCase2 tests and they are working fine. This is my setup protected void setUp() throws Exception { super.setUp(); Intent intent = new Intent(getInstrumentation().getTargetContext(), MyActivity.class); startActivity(intent, null, null); // The exception

Getting Nullpointer exception when UnitTesting Android TabActivity

南笙酒味 提交于 2019-12-10 20:13:50
问题 I am currently unittesting the sample TabLayout from android website. I am getting a NullPointerException when unittesting it like this: public class MainActivityUnitTest extends ActivityUnitTestCase<MainActivity>{ public MainActivityUnitTest(){ super(MainActivity.class); } @MediumTest public void testStartActivity(){ setActivity(startActivity(new Intent(Intent.ACTION_MAIN), null, null)); } } This is the exception that I am getting: java.lang.NullPointerException at android.app

Android Unit Tests with AppCompat project library

不羁岁月 提交于 2019-12-06 14:03:20
I have a project with some unit tests that extends ActivityUnitTestCase, but when I installed the android-support-v7-appcomapt project library to use the ActionBar, these tests have stopped working. I also have some ActivityInstrumentationTestCase2 tests and they are working fine. This is my setup protected void setUp() throws Exception { super.setUp(); Intent intent = new Intent(getInstrumentation().getTargetContext(), MyActivity.class); startActivity(intent, null, null); // The exception happens here veActivity = getActivity(); //getInstrumentation().callActivityOnStart(veActivity); } If I

Test run failed: Instrumentation run failed due to 'Process crashed.' when testing multiple Android activity

橙三吉。 提交于 2019-12-03 23:51:28
问题 I've got an issue with testing my android application. I have 2 testCase class, if I execute them separately, there is no problem, the tests run until the end. But if I do "right-click" on my test project and choose "Run as Android Junit Test" I've got a message Launching instrumentation android.test.InstrumentationTestRunner on device emulator-5554 [2012-03-27 15:56:27 - matroussedemaquillageTest] Collecting test information [2012-03-27 15:56:31 - matroussedemaquillageTest] Test run failed:

Android - AssertionFailedError on startActivity method in ActivityUnitTestCase test class

筅森魡賤 提交于 2019-12-03 11:06:41
问题 I am trying to test an activity in a module. I am just trying to start this activity in the test method, but I always have a AssertionFailedError . I searched the web for this issue but could not find any solution. Any help is appreciated. This is my test class: public class ContactActivityTest extends ActivityUnitTestCase<ContactActivity> { public ContactActivityTest() { super(ContactActivity.class); } @Override public void setUp() throws Exception { super.setUp(); } public void

Android - AssertionFailedError on startActivity method in ActivityUnitTestCase test class

微笑、不失礼 提交于 2019-12-03 01:29:19
I am trying to test an activity in a module. I am just trying to start this activity in the test method, but I always have a AssertionFailedError . I searched the web for this issue but could not find any solution. Any help is appreciated. This is my test class: public class ContactActivityTest extends ActivityUnitTestCase<ContactActivity> { public ContactActivityTest() { super(ContactActivity.class); } @Override public void setUp() throws Exception { super.setUp(); } public void testWebViewHasNotSetBuiltInZoomControls() throws Exception { Intent intent = new Intent(getInstrumentation()

Test run failed: Instrumentation run failed due to 'Process crashed.' when testing multiple Android activity

拈花ヽ惹草 提交于 2019-12-01 02:41:00
I've got an issue with testing my android application. I have 2 testCase class, if I execute them separately, there is no problem, the tests run until the end. But if I do "right-click" on my test project and choose "Run as Android Junit Test" I've got a message Launching instrumentation android.test.InstrumentationTestRunner on device emulator-5554 [2012-03-27 15:56:27 - matroussedemaquillageTest] Collecting test information [2012-03-27 15:56:31 - matroussedemaquillageTest] Test run failed: Instrumentation run failed due to 'Process crashed.' see bellow for my two testClasses: the first test

How to set Unit Test to Fragment in Android

♀尐吖头ヾ 提交于 2019-11-30 10:38:14
问题 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