Mobile Application Development MyRent Tester …...2016/11/01  · Mobile Application Development...

Post on 25-Jun-2020

3 views 0 download

transcript

Mobile Application DevelopmentMyRent Tester (JUnit)

Waterford Institute of Technology

November 1, 2016

John Fitzgerald

Waterford Institute of Technology, Mobile Application Development MyRent Tester (JUnit) 1/14

JUnit TesterLearning objectives

• How to create basic JUnit test app?• How to use Retrofit to enable tester-service communication?

Waterford Institute of Technology, Mobile Application Development MyRent Tester (JUnit) 2/14

MyRent service appJUnit test - service

Waterford Institute of Technology, Mobile Application Development MyRent Tester (JUnit) 3/14

MyRent test appUse to test service before client dev

• Create a Play app.• Customize models

and test classes.• No user interface.• No JPA relationships.• Service uses Gson

converters:• Json to Residence.• Residence to Json.

Waterford Institute of Technology, Mobile Application Development MyRent Tester (JUnit) 4/14

ModelRefactor Residence model class

• Override Object.equals

Waterford Institute of Technology, Mobile Application Development MyRent Tester (JUnit) 5/14

HTTP ClientRetrofit integration requires API & proxy classes

• API & Proxy classes

Waterford Institute of Technology, Mobile Application Development MyRent Tester (JUnit) 6/14

HTTP ClientRetrofit integration requires API & proxy classes

• API class

Waterford Institute of Technology, Mobile Application Development MyRent Tester (JUnit) 7/14

HTTP ClientRetrofit integration requires API & proxy classes

• API class

Waterford Institute of Technology, Mobile Application Development MyRent Tester (JUnit) 8/14

HTTP ClientRetrofit integration requires API & proxy classes

• Proxy class

Waterford Institute of Technology, Mobile Application Development MyRent Tester (JUnit) 9/14

MyRent service appRoutes - API

Test client app communicates with service using these patterns:

Waterford Institute of Technology, Mobile Application Development MyRent Tester (JUnit) 10/14

MyRent test codeSkeleton class

public class ResidenceTest {

@Beforepublic void setup() throws Exception {

}

@Afterpublic void teardown() throws Exception {

}

@Testpublic void getResidences() throws Exception {

}. . .

}

Waterford Institute of Technology, Mobile Application Development MyRent Tester (JUnit) 11/14

MyRent test codeSample test method

Retrieve all residence records over network & test

Waterford Institute of Technology, Mobile Application Development MyRent Tester (JUnit) 12/14

ReferencesPlay Framework JUnit Test application

1.Play: Testing your applicationhttps://goo.gl/1gbzlH [Accessed 2016-10-30]

Waterford Institute of Technology, Mobile Application Development MyRent Tester (JUnit) 13/14

Waterford Institute of Technology, Mobile Application Development MyRent Tester (JUnit) 14/14