Download - Unit Testing Android Application
Transcript
![Page 1: Unit Testing Android Application](https://reader035.vdocuments.net/reader035/viewer/2022080906/55a64d3a1a28abfc028b47f3/html5/thumbnails/1.jpg)
Unit Testing on
AndroidHussain Mansoor
![Page 2: Unit Testing Android Application](https://reader035.vdocuments.net/reader035/viewer/2022080906/55a64d3a1a28abfc028b47f3/html5/thumbnails/2.jpg)
Frameworks Required Mockito (doesn’t handle final, static and anonymous
class)
PowerMock (wrapper on top of Mockito)
RoboElectric (executes UT on Dalvik VM)
JSONAssert (to verify JSON data)
JUnit (to help with assertions)
![Page 3: Unit Testing Android Application](https://reader035.vdocuments.net/reader035/viewer/2022080906/55a64d3a1a28abfc028b47f3/html5/thumbnails/3.jpg)
Concepts What Unit Test covers?
What to Test?
Mocking a Layer
Injecting code into layer
Stubbing a method
Set up method
Tear Down method
Ignore Exception Handling
![Page 4: Unit Testing Android Application](https://reader035.vdocuments.net/reader035/viewer/2022080906/55a64d3a1a28abfc028b47f3/html5/thumbnails/4.jpg)
Types of mocking static mock
PowerMockito.mockStatic(DefaultHttpClient.class);
Singleton class
PowerMockito.suppress(PowerMockito.constructor(S
ession.class));
final method
private method
![Page 5: Unit Testing Android Application](https://reader035.vdocuments.net/reader035/viewer/2022080906/55a64d3a1a28abfc028b47f3/html5/thumbnails/5.jpg)
Stub PowerMockito.stub(
PowerMockito.method(
ParentPostRequest.class, ”methodNameToStubed")
).toReturn(false);
![Page 6: Unit Testing Android Application](https://reader035.vdocuments.net/reader035/viewer/2022080906/55a64d3a1a28abfc028b47f3/html5/thumbnails/6.jpg)
Arguments to methods