![Page 1: Mobile Application Development MyRent Tester …...2016/11/01 · Mobile Application Development MyRent Tester (JUnit) WaterfordInstituteofTechnology November1,2016 JohnFitzgerald](https://reader035.vdocuments.net/reader035/viewer/2022081405/5f0d21ac7e708231d438d5ae/html5/thumbnails/1.jpg)
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
![Page 2: Mobile Application Development MyRent Tester …...2016/11/01 · Mobile Application Development MyRent Tester (JUnit) WaterfordInstituteofTechnology November1,2016 JohnFitzgerald](https://reader035.vdocuments.net/reader035/viewer/2022081405/5f0d21ac7e708231d438d5ae/html5/thumbnails/2.jpg)
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
![Page 3: Mobile Application Development MyRent Tester …...2016/11/01 · Mobile Application Development MyRent Tester (JUnit) WaterfordInstituteofTechnology November1,2016 JohnFitzgerald](https://reader035.vdocuments.net/reader035/viewer/2022081405/5f0d21ac7e708231d438d5ae/html5/thumbnails/3.jpg)
MyRent service appJUnit test - service
Waterford Institute of Technology, Mobile Application Development MyRent Tester (JUnit) 3/14
![Page 4: Mobile Application Development MyRent Tester …...2016/11/01 · Mobile Application Development MyRent Tester (JUnit) WaterfordInstituteofTechnology November1,2016 JohnFitzgerald](https://reader035.vdocuments.net/reader035/viewer/2022081405/5f0d21ac7e708231d438d5ae/html5/thumbnails/4.jpg)
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
![Page 5: Mobile Application Development MyRent Tester …...2016/11/01 · Mobile Application Development MyRent Tester (JUnit) WaterfordInstituteofTechnology November1,2016 JohnFitzgerald](https://reader035.vdocuments.net/reader035/viewer/2022081405/5f0d21ac7e708231d438d5ae/html5/thumbnails/5.jpg)
ModelRefactor Residence model class
• Override Object.equals
Waterford Institute of Technology, Mobile Application Development MyRent Tester (JUnit) 5/14
![Page 6: Mobile Application Development MyRent Tester …...2016/11/01 · Mobile Application Development MyRent Tester (JUnit) WaterfordInstituteofTechnology November1,2016 JohnFitzgerald](https://reader035.vdocuments.net/reader035/viewer/2022081405/5f0d21ac7e708231d438d5ae/html5/thumbnails/6.jpg)
HTTP ClientRetrofit integration requires API & proxy classes
• API & Proxy classes
Waterford Institute of Technology, Mobile Application Development MyRent Tester (JUnit) 6/14
![Page 7: Mobile Application Development MyRent Tester …...2016/11/01 · Mobile Application Development MyRent Tester (JUnit) WaterfordInstituteofTechnology November1,2016 JohnFitzgerald](https://reader035.vdocuments.net/reader035/viewer/2022081405/5f0d21ac7e708231d438d5ae/html5/thumbnails/7.jpg)
HTTP ClientRetrofit integration requires API & proxy classes
• API class
Waterford Institute of Technology, Mobile Application Development MyRent Tester (JUnit) 7/14
![Page 8: Mobile Application Development MyRent Tester …...2016/11/01 · Mobile Application Development MyRent Tester (JUnit) WaterfordInstituteofTechnology November1,2016 JohnFitzgerald](https://reader035.vdocuments.net/reader035/viewer/2022081405/5f0d21ac7e708231d438d5ae/html5/thumbnails/8.jpg)
HTTP ClientRetrofit integration requires API & proxy classes
• API class
Waterford Institute of Technology, Mobile Application Development MyRent Tester (JUnit) 8/14
![Page 9: Mobile Application Development MyRent Tester …...2016/11/01 · Mobile Application Development MyRent Tester (JUnit) WaterfordInstituteofTechnology November1,2016 JohnFitzgerald](https://reader035.vdocuments.net/reader035/viewer/2022081405/5f0d21ac7e708231d438d5ae/html5/thumbnails/9.jpg)
HTTP ClientRetrofit integration requires API & proxy classes
• Proxy class
Waterford Institute of Technology, Mobile Application Development MyRent Tester (JUnit) 9/14
![Page 10: Mobile Application Development MyRent Tester …...2016/11/01 · Mobile Application Development MyRent Tester (JUnit) WaterfordInstituteofTechnology November1,2016 JohnFitzgerald](https://reader035.vdocuments.net/reader035/viewer/2022081405/5f0d21ac7e708231d438d5ae/html5/thumbnails/10.jpg)
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
![Page 11: Mobile Application Development MyRent Tester …...2016/11/01 · Mobile Application Development MyRent Tester (JUnit) WaterfordInstituteofTechnology November1,2016 JohnFitzgerald](https://reader035.vdocuments.net/reader035/viewer/2022081405/5f0d21ac7e708231d438d5ae/html5/thumbnails/11.jpg)
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
![Page 12: Mobile Application Development MyRent Tester …...2016/11/01 · Mobile Application Development MyRent Tester (JUnit) WaterfordInstituteofTechnology November1,2016 JohnFitzgerald](https://reader035.vdocuments.net/reader035/viewer/2022081405/5f0d21ac7e708231d438d5ae/html5/thumbnails/12.jpg)
MyRent test codeSample test method
Retrieve all residence records over network & test
Waterford Institute of Technology, Mobile Application Development MyRent Tester (JUnit) 12/14
![Page 13: Mobile Application Development MyRent Tester …...2016/11/01 · Mobile Application Development MyRent Tester (JUnit) WaterfordInstituteofTechnology November1,2016 JohnFitzgerald](https://reader035.vdocuments.net/reader035/viewer/2022081405/5f0d21ac7e708231d438d5ae/html5/thumbnails/13.jpg)
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
![Page 14: Mobile Application Development MyRent Tester …...2016/11/01 · Mobile Application Development MyRent Tester (JUnit) WaterfordInstituteofTechnology November1,2016 JohnFitzgerald](https://reader035.vdocuments.net/reader035/viewer/2022081405/5f0d21ac7e708231d438d5ae/html5/thumbnails/14.jpg)
Waterford Institute of Technology, Mobile Application Development MyRent Tester (JUnit) 14/14