実践Android Developer Testing

11,266 views

Published on

Published in: Self Improvement, Technology
1 Comment
23 Likes
Statistics
Notes
No Downloads
Views
Total views
11,266
On SlideShare
0
From Embeds
0
Number of Embeds
5,502
Actions
Shares
0
Downloads
136
Comments
1
Likes
23
Embeds 0
No embeds

No notes for slide

実践Android Developer Testing

  1. 1. Android Developer Testing Developers Summit 201212 2 17
  2. 2.  / @snsk  Android / NPO ASTER WG / ACCESS  @nowsprinting  Developers Summit 201212 2 17
  3. 3.  Model @mike_neck  Android Java Javascript Groovy SIer  SQLite @ussy00  Android  Developers Summit 201212 2 17
  4. 4. Android (ATEC)  Android    Developers Summit 201212 2 17
  5. 5.  ( ) 1 MTG  Android  ABC /JaSST LT  @IT Android  400  2012/2 423 Developers Summit 201212 2 17
  6. 6.    Android  Android  SDK    Android  Android Developers Summit 201212 2  Testter 17
  7. 7.   Sponsored by  @IT  CI Developers Summit 201212 2 17
  8. 8. • o https://sites.google.com/site/ androidtestclub/members • →Testter o https://sites.google.com/site/ androidtestclub/testter • o https://sites.google.com/site/ androidtestclub/business-card Developers Summit 201212 2 17
  9. 9. Developers Summit 201212 2 17
  10. 10. v2.0.J01 Developers Summit 201212 2 17
  11. 11. Developers Summit 201212 2 17
  12. 12. 3 Drive JUDGE Report 3 Developers Summit 201212 2 17
  13. 13. Developers Summit 201212 2 17
  14. 14.  Robotium  View GUI  monkeyrunner  Developers Summit 201212 2 17
  15. 15. 11 / Developers Summit 201212 2 17
  16. 16. View 1/3  ActivityInstrumentationTestCase2  Android SDK android.test JUnit3   Robotium  ↑ Activity  scirocco  ↑ Developers Summit 201212 2 17
  17. 17. View 2/3  NativeDriver  By Google. 2011/6 ASL 2.0  JUnit   apk server-standalone.jar  WebDriver, NativeDriver for iOS Developers Summit 201212 2 17
  18. 18. View 3/3  FoneMonkey  By Gorilla Logic. 2011/11 GPL v3  GUI  recording/playback  JUnit export TestRunner  FlaxMonkey, FoneMonkey for iOS Developers Summit 201212 2 17
  19. 19.  monkeyrunner  Android SDK  Python   monkeyrecorder/playback.py  Developers Summit 201212 2 17
  20. 20.  Monkey  Android SDK   SIKULI   PC Android Developers Summit 201212 2 17
  21. 21.  Android Testing Framework  AndroidTestCase ActivityUnitTestCase  @IT 2 3  AndroidMock  EastMock Android  @IT 5 3  Robolectric  JavaVM Android Developers Summit 201212 2 17
  22. 22. GUI Developers Summit 201212 2 17
  23. 23.   Android     Developers Summit 201212 2 17
  24. 24.   Judge   UI  UI  ActionBar … Developers Summit 201212 2 17
  25. 25.    Developers Summit 201212 2 17
  26. 26. Developers Summit 201212 2 17
  27. 27. Android • Activity • ( C ) Developers Summit 201212 2 17
  28. 28. Android Activity onCreate(Bundle bundle) { // // // // ( ) // } Developers Summit 201212 2 17
  29. 29. Android Activity onCreate(Bundle bundle) { // // →C // →M // ( ) →V // →V/C } Developers Summit 201212 2 17
  30. 30. Android OnClickListener onClick(View view) { // // // ( ) // } Developers Summit 201212 2 17
  31. 31. Android OnClickListener onClick(View view) { // →C // →M // ( ) →V // →V/C } Developers Summit 201212 2 17
  32. 32. Activity Model View Model Developers Summit 201212 2 17
  33. 33. Activity http://goo.gl/YiH1w Developers Summit 201212 2 17
  34. 34. Model - • o o • o o Developers Summit 201212 2 17
  35. 35. Android • Database (SQLite3) • (SNS ) • o o o GPS Developers Summit 201212 2 17
  36. 36. • Activity Activity • Activity Developers Summit 201212 2 17
  37. 37. • Model View • Model View • Model View Developers Summit 201212 2 17
  38. 38. Developers Summit 201212 2 17
  39. 39. Developers Summit 201212 2 17
  40. 40. Developers Summit 201212 2 17
  41. 41. • o • o ActivityInsterumentationTestCase2<T extends Activity> setUp Developers Summit 201212 2 17
  42. 42. Developers Summit 201212 2 17
  43. 43. Developers Summit 201212 2 17
  44. 44. • ActivityInstrumentationTestCase2<T extends Activity> getActivity Activity onCreate onResume • Activity Database • Activity View Developers Summit 201212 2 17
  45. 45. • ActivityInstrumentationTestCase2<T extends Activity> getActivity Activity onCreate onResume • Activity Database • Activity View  → Developers Summit 201212 2 17
  46. 46.  onCreate Developers Summit 201212 2 17
  47. 47. Thread Developers Summit 201212 2 17
  48. 48. Activity Thread onCreate Developers Summit 201212 2 17
  49. 49. Activity  Activity Model Developers Summit 201212 2 17
  50. 50. Model Activity Developers Summit 201212 2 17
  51. 51. Developers Summit 201212 2 17
  52. 52. Model View Developers Summit 201212 2 17
  53. 53. ActivityInstrumentation TestCase2<T extends Activity> • View • Model View Unit Test • Model Thread Activity Developers Summit 201212 2 17
  54. 54. ActivityInstrumentation TestCase2<T extends Activity> • View • Model View Unit Test • Model Thread Activity Developers Summit 201212 2 17
  55. 55. • Model Thread Activity • o × = ( ) Developers Summit 201212 2 17
  56. 56. Android Activity Developers Summit 201212 2 17
  57. 57. SQLite Developers Summit 201212 2 17
  58. 58.  SQL @Override protected void setUp() throws Exception { super.setUp(); helper = new AllowanceDatabase(new RenamingDelegatingContext(getContext(), "test_")); SQLiteDatabase db = helper.getWritableDatabase(); try { db.execSQL("INSERT INTO ALLOWANCE_LOG(LOG_DATE, AMOUNT) VALUES(1320000000, 1000);"); db.execSQL("INSERT INTO ALLOWANCE_LOG(LOG_DATE, AMOUNT) VALUES(1330000000, 5000);"); db.execSQL("INSERT INTO ALLOWANCE_LOG(LOG_DATE, AMOUNT) VALUES(1340000000, 10000);"); db.execSQL("INSERT INTO ALLOWANCE_LOG(LOG_DATE, AMOUNT) VALUES(1350000000, 2000);"); db.execSQL("INSERT INTO ALLOWANCE_LOG(LOG_DATE, AMOUNT) VALUES(1360000000, 3000);"); } finally { db.close(); } } Developers Summit 201212 2 17
  59. 59. Fixture Library   DBUnit (Java)  ActiveRecord (Ruby)  Test::Fixture::DBI (Perl)  fixture (Python)  Factory Girl (Ruby)  ???? (Android) Developers Summit 201212 2 17
  60. 60. Fixture for Android  SQLite Fixture Library  https://github.com/ussy/sqlite-fixture   DB  RenamingDelegatingContext Developers Summit 201212 2 17
  61. 61.  @Override protected void setUp() throws Exception { super.setUp(); importData(FileType.Yaml, "AllowanceLogDataTest"); } Developers Summit 201212 2 17
  62. 62. --- _id: 1 LOG_DATE: 1320000000 AMOUNT: 1000 --- _id: 2 LOG_DATE: 1330000000 AMOUNT: 5000 --- _id: 3 LOG_DATE: 1340000000 AMOUNT: 10000 Developers Summit 201212 --- 2 17
  63. 63. Fixture Library    Developers Summit 201212 2 17
  64. 64.  API  Developers Summit 201212 2 17
  65. 65. Developers Summit 201212 2 17
  66. 66.    Developers Summit 201212 2 17
  67. 67. DB Developers Summit 201212 2 17
  68. 68.  SQLiteOpenHelper https://github.com/ussy/android-dbtest Developers Summit 201212 2 17
  69. 69. private Context context; protected void setUp() { context = new RenamingDelegatingContext(getContext(), "test_"); helper = new SQLiteOpenHelperV1(context); } public void testMigration() { helper = SQLiteOpenHelperFactory.get(context); // test code } Developers Summit 201212 2 17
  70. 70. Developers Summit 201212 2 17
  71. 71. CI   Developers Summit 201212 2 17
  72. 72. Jenkins Developers Summit 201212 2 17
  73. 73. Android Emulator Plugin    APK  Android   OS Developers Summit 201212 2 17
  74. 74. Developers Summit 201212 2 17
  75. 75.    Jenkins  Developers Summit 201212 2 17
  76. 76. 3  Level1 Automation  Record Playback  Liner Script  Level2 Automation  Data-driven  Functional Decomposition  Level3 Automation  Keyword Driven  Model-based TEST AUTOMATIONBODY OF KNOWLEDGE(TABOK) GUIDEBOOK Version 1.1 Developers Summit 201212 2 17
  77. 77. 3 1. 2. 3. *1 *1 3 Developers Summit 201212 2 17
  78. 78. Developers Summit 201212 2 17

×