Questions tagged [activityunittestcase]

26 questions
48
votes
4 answers

How to set Unit Test to Fragment in Android

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…
20
votes
1 answer

Android - AssertionFailedError on startActivity method in ActivityUnitTestCase test class

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…
14
votes
4 answers

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

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…
Simon Mardiné
  • 510
  • 2
  • 7
  • 23
13
votes
1 answer

ActivityUnitTestCase throws RuntimeException when ran with AndroidJUnitRunner

I am trying to integrate Espresso 2.0's AndoridJUnitRunner with ActivityUnitTestCase. However, my tests are crashing when startActivity() tries to initialize mMockParent = new MockParent(). Here's what I did: Create a new project with Intellij 14 CE…
12
votes
4 answers

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

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…
3
votes
4 answers

Getting Nullpointer exception when UnitTesting Android TabActivity

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{ public…
3
votes
1 answer

btn.performClick() Unable mock Object,but Activity call the function is able

I have try test button function using Mockito. The code include Layout/SampleActivity/UnitTest major Content: layout file define: android:text="testbtnmock" android:id="@+id/btn_testbtnmock" android:onClick="testBtnMock" SampleActivity file…
3
votes
2 answers

getStartedActivityIntent returns null in Unit Test Case using ActivityUnitTestCase

I am writing Unit test case to test an Activity. Extending ActivityUnitTestCase class. Launching basic intent first. Then using TouchUtils, Performing intended actions. there is startActivity() call in my action. While debugging code i am able to…
Meghana M
  • 535
  • 4
  • 21
2
votes
2 answers

Android Unit Tests with AppCompat project library

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…
2
votes
1 answer

Android Testing: Checking the LeftDrawable image is correct

Method being Tested (In Main Activity) //This Method allows you to set the LeftDrawable Image to a grayed out (drawableDown) //image for 300 millseconds then returns the LeftDrawable Image back to the orignal //(drawableUp).On a button. void…
Jake Graham Arnold
  • 1,416
  • 2
  • 19
  • 40
1
vote
1 answer

Activity Unit testing using ActivityUnitTestCase

I am trying to write Unit tests for activity methods using ActivityUnitTestCase. But always i am getting null pointer exception while calling startActivity(). Below is my code. I debugged and found this always returning null…
vinothp
  • 9,939
  • 19
  • 61
  • 103
1
vote
1 answer

Testing GoogleApiClient in Android Instrumentation TestCase

I am writing a testcase of activity with ActivityInstrumentationTestCase2. In this activity I am using GoogleApiClient to get the location of the user. I want the assert that GoogleApiClient is connected. This is the testcase i…
1
vote
2 answers

You need to use a Theme.AppCompat theme --> in Unit Test

I know this topic has been discussed but it is a little different here: App works fine Error is displayed only in unit test Theme is Fine (new created sample project) How to reproduce: Create just a new project --> FullScreenActivity Android…
Paul
  • 193
  • 1
  • 8
1
vote
0 answers

How to run unit test case with activity in landscape orientation

I'm writing test case for my android application. One of my activity has landscape and portrait xml files in respective folders. I have TextView only in landscape xml file. How to run my test case by forcing the activity in landscape orientation. …
Vignesh
  • 2,295
  • 7
  • 33
  • 41
1
vote
1 answer

How to execute phpunit in browsers?

I am working in web application project using php, mysql and zend framework extension classes. And my task is to write unit test case for web application. I read following document https://phpunit.de/manual/4.3/en/installation.html and saw some…
Kumar Shanmugam
  • 597
  • 1
  • 11
  • 40
1
2