既存のAndroidアプリをリファクタリングしていく話

 既存のAndroidアプリをリファクタリングしていく話

4b7536b1ad854fa552a2cea0248bb5cc?s=128

hisaichi5518

July 02, 2016
Tweet

Transcript

  1. !IJTBJDIJ(.01&1"#0JOD طଘͷ"OESPJEΞϓϦΛ ϦϑΝΫλϦϯά͍ͯ͘͠

  2. γχΞΤϯδχΞ !IJTBJDIJ ٢ߴ༝ཬࢠ٢ߴ༝ཬࢠ٢ߴ༝ཬࢠ XXXZPTIJUBLBZVSJLPDPN

  3. NJOOF ϛϯω

  4. ࠓ͸ɺ"OESPJEΞϓϦΛ୲౰த

  5. طଘͷ"OESPJEΞϓϦΛ ϦϑΝΫλϦϯά͢Δ࿩

  6. ͳʹΛ࿩͔͢ w͍͔ͭ͘ى͖ͨ໰୊ʹ͍ͭͯɾͲ͏΍ͬͯղܾ͔ͨ͠

  7. ࿩͞ͳ͍͜ͱ w3Y+BWBͱ͔%BUB#JOEJOHͱ͔φ΢͍ϥΠϒϥϦͷ࿩ w௒ઈඒ͍͠ઃܭͷ࿩

  8. None
  9. ೥ळʙ w"OESPJEΞϓϦͷ։ൃελʔτ w౰ॳ͸"OESPJEνʔϜ͸ਓ wJ04ΞϓϦʹൺ΂ͯػೳͷ͕ࠩ͋ͬͨͷͰɺͱʹ͔͘ ։ൃεϐʔυ༏ઌ wIUUQTQFQBCPDPNSFDSVJUJOUFSWJFX @

  10. ೥Նʙ w"OESPJEΞϓϦνʔϜ͕ਓʹͳͬͨ wࣗ෼΋͜ͷࠒʹ"OESPJEνʔϜʹೖͬͨ

  11. ͜Ε͔Βόʔϯͱ͍ͧ͘ʙʂ

  12. ໰୊ൃੜ

  13. ςετ͕ͳ͍໰୊

  14. ͳͥςετ͕ඞཁͳͷ͔ wΑΓ৴པग़དྷΔΞϓϦʹ͠ͳ͚Ε͹ͳΒͳ͍͔Β

  15. ৴པग़དྷΔΞϓϦͬͯͳʹ wΞϓϦʹόά͕গͳ͍ wΞϓϦ͕ಥવམͪͳ͍ wαʔϏεӡӦݩ͕৴༻ग़དྷΔ wͳͲͳͲ༷ʑͳཁҼ͕͋Δ

  16. ৴པग़དྷΔΞϓϦͬͯͳʹ wΞϓϦʹόά͕গͳ͍ wΞϓϦ͕ಥવམͪͳ͍ wαʔϏεӡӦݩ͕৴༻ग़དྷΔ wͳͲͳͲ༷ʑͳཁҼ͕͋Δ ຬ͍ͨͨ͠

  17. ৴པग़དྷΔΞϓϦʹͳΔͨΊ ςετ͸ඞཁ

  18. ςετͳ͍໰୊Λ ղܾ͢ΔͨΊʹ΍ͬͨ͜ͱ

  19. ղܾ͢ΔͨΊʹ w6*ςετΛॻ͘ wςετͷ೔ͷಋೖ w%FWJDF'BSNΛ࢖͏

  20. 6*ςετΛॻ͜͏ wϙνϙνςετΛগ͠͸ࣗಈԽ͍ͨ͠ w&TQSFTTPΛར༻͍ͯ͠·͢

  21. 1 @RunWith(AndroidJUnit4.class) 2 @LargeTest 3 public class HelloWorldEspressoTest { 4

    5 @Rule 6 public ActivityTestRule<MainActivity> mActivityRule 7 = new ActivityTestRule(MainActivity.class); 8 9 @Test 10 public void listGoesOverTheFold() { 11 onView(withText("Hello world!")).check(matches(isDisplayed())); 12 } 13 }
  22. 1 @RunWith(AndroidJUnit4.class) 2 @LargeTest 3 public class HelloWorldEspressoTest { 4

    5 @Rule 6 public ActivityTestRule<MainActivity> mActivityRule 7 = new ActivityTestRule(MainActivity.class); 8 9 @Test 10 public void listGoesOverTheFold() { 11 onView(withText("Hello world!")).check(matches(isDisplayed())); 12 } 13 }
  23. ςετͷ೔ͷಋೖ wςετΛॻ͘͜ͱʹ׳Εͯͳ͍ਓ͕ଟ͔ͬͨ wςετΛॻ͘͜ͱʹ׳ΕΔͨΊʹ΋ɺςετ͚ͩΛॻ ͘೔Λिؒʹ౓ઃ͚Δ͜ͱʹͨ͠

  24. %FWJDF'BSNͷར༻ w6*ςετΛॻ͍ͯ΋ܧଓతʹ࣮ߦ͍ͯ͠ͳ͍ͱҙຯ͕ ͳ͍ w"NB[PO͕ࣾఏڙ͢Δʮ࣮ࡍͷσόΠεΛར༻ͯ͠ς ετΛ࣮ߦͯ͘͠ΕΔʯαʔϏε wϒϥϯνຖʹ࣮ߦ͢ΔΑ͏ʹͯ͠ɺςετ͕௨Βͳ͍ ͱϚʔδ͠ͳ͍ϧʔϧΛܾΊͨ

  25. ਐΊํ

  26. ػೳ։ൃ͸ͦͷ··ਐΊΔ wػೳ։ൃ͸ͦͷ··ਐΊͳ͕Βɺ৽͘͠։ൃ͢Δͱ͜ ΖͷςετΛͳΔ΂͘ॻ͍͍ͯ͘ํ਑ wνʔϜϝϯόʔ͕૿͑ͨͷ͸ػೳ։ൃΛΑΓεϜʔζ ʹߦ͏ͨΊͳͷͰɺςετΛॻ͘ͱ͍͏͜ͱ͸ػೳ։ ൃΛࢭΊͯ·Ͱ΍Δ͜ͱͰ͸ͳ͔ͬͨ

  27. δϫδϫͱ6*ςετ͕ ૿͖͑ͯͨ

  28. ໰୊ൃੜ

  29. 6*ςετͭΒ͍໰୊

  30. 6*ςετͷͳʹ͕ͭΒ͍ wλΠϛϯά࣍ୈͰ࣌ʑίέΔςετ͕૿͑ͨ wେ͖ΊͷมߋΛߦ͏ͱ6*ςετͷ࡞Γ௚͠ʹͳͬͯԿ ౓΋6*ςετΛॻ͖௚ͯ͠Δ w6*ςετͷ࣮ߦ͕࣌ؒ௕ͯ͘ɺ଴͕ͭ࣌ؒ૿͑ͨ wͦ΋ͦ΋6*ςετΛॻͨ͘Ίʹ֮͑Δࣄ͕ଟͯ͘େม

  31. ςετΛͭΒ͍΋ͷආ͚͍ͨ΋ͷʹ͸ ͨ͘͠ͳ͍ͷͰղܾ͍ͨ͠

  32. 6*ςετΑΓ୯ମςετͷ ΄͏͕ྑ͍ؾ͕͢Δ

  33. 6*ςετWT୯ମςετ w6*ςετ͸ɺςετͷ୯Ґ͕େ͖͍ w୯ମςετ͸ɺϝιου୯ҐͰਖ਼͘͠ಈ࡞͢Δͷ͔ݕ ূ͢ΔͷͰςετͷ୯Ґ͕খ͍͞ w୯ମςετ͸ɺ֮͑Δ͜ͱ΋গͳ͍

  34. ΍ͬͺ୯ମςετͷ΄͏͕ ྑ͍ؾ͕͢Δ

  35. ͳͥ๻ͨͪ͸6*ςετΛॻ ͍͍ͯΔΜͩ

  36. "OESPJE5FTUͰͳ͍ͱಈ͔ͳ͍ Ϋϥεͷதʹςετ͍ͨ͠΋ͷ͕ ͋Δ

  37. ͳͥ୯ମςετͷதͰಈ͔ͳ͍Ϋϥε ͷதʹςετ͍ͨ͠΋ͷ͕͋Δ

  38. ̍ͭͷΫϥεͷ੹຿͕େ͖͗͢ɻ Ϋϥεͷ੹຿Λখ͘͞ग़དྷ͍ͯͳ ͍

  39. ͭͷΫϥεʹ٧ΊࠐΈա͗໰୊

  40. ͳͥͭͷΫϥεʹ٧ΊࠐΈա͗Δͱ໰୊ͳͷ͔ w୯ମςετ͕ॻ͖ʹ͍͘ wαʔϏεΛΑΓ੒௕ͤ͞Δʹ͸ɺมԽʹڧ͘ͳ͚Ε͹ ͳΒͳ͍

  41. มԽʹڧ͍ wมԽʹڧ͍ͱ͸ɺʮίʔυͷཧղ͕͠΍͍͢ʯʮมߋ ΛՃ͑΍͍͢ʯʮՃ͑ͨมߋͷӨڹΛཧղ͠΍͍͢ʯ Λࢦ͢

  42. ͭͷΫϥεʹ٧ΊࠐΈա͗Δͱʜ wʮίʔυͷཧղ͕͠ʹ͍͘ʯʮมߋΛՃ͑ʹ͍͘ʯʮՃ ͑ͨมߋͷӨڹΛཧղ͠ʹ͍͘ʯ w୯ମςετͰςετ͠ʹ͍͘

  43. ͳͷͰ ͭͷΫϥεʹ٧ΊࠐΈ͗͢͸໰୊

  44. ͭͷΫϥεʹ٧ΊࠐΈա͗໰୊Λ ղܾ͢ΔͨΊʹ΍ͬͨ͜ͱ

  45. ͳͥ੹຿Λখ͘͞ग़དྷ͍ͯ ͳ͍ͷ͔

  46. Ϋϥε͕ԿΛ୲౰͢΂͖ͳͷ͔໌֬ ʹܾ·͍ͬͯͳ͍͔Β

  47. ͭ·Γɺܾ·ΓࣄΛܾΊͯ͋͛Ε͹Α͍

  48. ܾ·ΓࣄΞʔΩςΫνϟ

  49. .71ΞʔΩςΫνϟΛ࠾༻͢Δ

  50. ϩδοΫ wϓϨθϯςʔγϣϯϩδοΫ wϏδωεϩδοΫ

  51. ϓϨθϯςʔγϣϯϩδοΫ ඞཁͳ஋ΛϏδωεϩδοΫʹ ౉͢·ͰͷৼΔ෣͍

  52. ϏδωεϩδοΫ "1*΍σʔλϕʔεͳͲ͔Β ஋Λಘͯɺฦ͢

  53. ϓϨθϯςʔγϣϯϩδοΫ ϏδωεϩδοΫ͔Β ฦ͖ͬͯͨ஋Λ੔ܗͯ͠ දࣔ͢ΔৼΔ෣͍

  54. None
  55. .71ΞʔΩςΫνϟ

  56. .7$ͷ೿ੜ

  57. .7$

  58. .PEFM7JFX$POUSPMMFS

  59. .7$͸"OESJPEΞϓϦʹ޲͍͍ͯͳ͍

  60. 7JFXͷૢ࡞  "DUJWJUZͰߦ͏

  61. $POUSPMMFS  "DUJWJUZʹॻ͘

  62. 7JFX $POUSPMMFS"DUJWJUZ

  63. Ϋϥεͷ੹຿Λখ͘͞ग़དྷ͍ͯͳ͍

  64. .7$͸"OESJPEΞϓϦʹ޲͍͍ͯͳ͍

  65. .71

  66. .PEFM7JFX1SFTFOUFS

  67. .PEFM wϏδωεϩδοΫΛॻ͘ w1SFTFOUFSʹґଘ͠ͳ͍ w7JFXʹґଘ͠ͳ͍

  68. 7JFX wϢʔβʔ͔ΒͷೖྗΛड͚औΔ wϢʔβʔ͔ΒͷೖྗΛ1SFTFOUFSʹ౉͢ wը໘ͷදࣔ΍ߋ৽Λߦ͏

  69. 1SFTFOUFS wϓϨθϯςʔγϣϯϩδοΫΛॻ͘ w7JFXͷߋ৽͸ɺJOUFSGBDFΛܦ༝ͯ͠ߦ͏

  70. .7$WT.71

  71. .7$

  72. 1 public class UserActivity extends AppCompatActivity { 2 @Override 3

    protected void onCreate(Bundle savedInstanceState) { 4 int userId = ...; 5 fetchUser(userId); 6 } 7 8 private void fetchUser(int userId) { 9 UserService service = ApiClient.getInstance().create(UsersService.class); 10 service.fetch(userId, new Callback<User>() { 11 @Override 12 public void success(User user, Response response) { 13 showName(name); 14 } 15 16 @Override 17 public void failure(RetrofitError error) { 18 showError(error); 19 } 20 }); 21 } 22 23 public void showName(String name) { 24 mTextView.setText(name); 25 } 26 27 public void showError(...) { ... } 28 }
  73. 1 public class UserActivity extends AppCompatActivity { 2 @Override 3

    protected void onCreate(Bundle savedInstanceState) { 4 int userId = ...; 5 fetchUser(userId); 6 } 7 8 private void fetchUser(int userId) { 9 UserService service = ApiClient.getInstance().create(UsersService.class); 10 service.fetch(userId, new Callback<User>() { 11 @Override 12 public void success(User user, Response response) { 13 showName(name); 14 } 15 16 @Override 17 public void failure(RetrofitError error) { 18 showError(error); 19 } 20 }); 21 } 22 23 public void showName(String name) { 24 mTextView.setText(name); 25 } 26 27 public void showError(...) { ... } 28 } ೖྗΛड͚औΔ ϓϨθϯςʔγϣϯϩδοΫ 7JFXͷߋ৽
  74. 1 public class UserActivity extends AppCompatActivity { 2 @Override 3

    protected void onCreate(Bundle savedInstanceState) { 4 int userId = ...; 5 fetchUser(userId); 6 } 7 8 private void fetchUser(int userId) { 9 UserService service = ApiClient.getInstance().create(UsersService.class); 10 service.fetch(userId, new Callback<User>() { 11 @Override 12 public void success(User user, Response response) { 13 showName(name); 14 } 15 16 @Override 17 public void failure(RetrofitError error) { 18 showError(error); 19 } 20 }); 21 } 22 23 public void showName(String name) { 24 mTextView.setText(name); 25 } 26 27 public void showError(...) { ... } 28 } ೖྗΛड͚औΔ
  75. 1 public class UserActivity extends AppCompatActivity { 2 @Override 3

    protected void onCreate(Bundle savedInstanceState) { 4 int userId = ...; 5 fetchUser(userId); 6 } 7 8 private void fetchUser(int userId) { 9 UserService service = ApiClient.getInstance().create(UsersService.class); 10 service.fetch(userId, new Callback<User>() { 11 @Override 12 public void success(User user, Response response) { 13 showName(name); 14 } 15 16 @Override 17 public void failure(RetrofitError error) { 18 showError(error); 19 } 20 }); 21 } 22 23 public void showName(String name) { 24 mTextView.setText(name); 25 } 26 27 public void showError(...) { ... } 28 } ϓϨθϯςʔγϣϯϩδοΫ
  76. 1 public class UserActivity extends AppCompatActivity { 2 @Override 3

    protected void onCreate(Bundle savedInstanceState) { 4 int userId = ...; 5 fetchUser(userId); 6 } 7 8 private void fetchUser(int userId) { 9 UserService service = ApiClient.getInstance().create(UsersService.class); 10 service.fetch(userId, new Callback<User>() { 11 @Override 12 public void success(User user, Response response) { 13 showName(name); 14 } 15 16 @Override 17 public void failure(RetrofitError error) { 18 showError(error); 19 } 20 }); 21 } 22 23 public void showName(String name) { 24 mTextView.setText(name); 25 } 26 27 public void showError(...) { ... } 28 } 7JFXͷߋ৽
  77. 1 public class UserActivity extends AppCompatActivity { 2 @Override 3

    protected void onCreate(Bundle savedInstanceState) { 4 int userId = ...; 5 fetchUser(userId); 6 } 7 8 private void fetchUser(int userId) { 9 UserService service = ApiClient.getInstance().create(UsersService.class); 10 service.fetch(userId, new Callback<User>() { 11 @Override 12 public void success(User user, Response response) { 13 showName(name); 14 } 15 16 @Override 17 public void failure(RetrofitError error) { 18 showError(error); 19 } 20 }); 21 } 22 23 public void showName(String name) { 24 mTextView.setText(name); 25 } 26 27 public void showError(...) { ... } 28 } ೖྗΛड͚औΔ ϓϨθϯςʔγϣϯϩδοΫ 7JFXͷߋ৽
  78. .71

  79. 1 public class UserActivity extends AppCompatActivity implements UserView { 2

    @Override 3 protected void onCreate(Bundle savedInstanceState) { 4 int userId = ...; 5 UserPresenter presenter = new UserPresenter(this); 6 presenter.fetchUser(userId); 7 } 8 9 @Override 10 public void showName(String name) { 11 mTextView.setText(name); 12 } 13 14 @Override 15 public void showError(...) { ... } 16 } 6TFS"DUJWJUZ
  80. 1 public class UserActivity extends AppCompatActivity implements UserView { 2

    @Override 3 protected void onCreate(Bundle savedInstanceState) { 4 int userId = ...; 5 UserPresenter presenter = new UserPresenter(this); 6 presenter.fetchUser(userId); 7 } 8 9 @Override 10 public void showName(String name) { 11 mTextView.setText(name); 12 } 13 14 @Override 15 public void showError(...) { ... } 16 } 1 public interface UserView { 2 void showName(String name); 3 void showError(...); 4 } 7JFXͷߋ৽ϝιου͕ఆٛ 6TFS7JFX
  81. 1 public class UserPresenter { 2 UserView mView; 3 4

    public UserPresenter(UserView view) { 5 mView = view; 6 } 7 8 public void fetchUser(int userId) { 9 UserService service = ApiClient.getInstance().create(UsersService.class); 10 service.fetch(userId, new Callback<User>() { 11 @Override 12 public void success(User user, Response response) { 13 mView.showName(user.getName()); 14 } 15 16 @Override 17 public void failure(RetrofitError error) { 18 mView.showError(error); 19 } 20 }); 21 } 22 } 6TFS1SFTFOUFS
  82. 1 public class UserActivity extends AppCompatActivity implements UserView { 2

    @Override 3 protected void onCreate(Bundle savedInstanceState) { 4 int userId = ...; 5 UserPresenter presenter = new UserPresenter(this); 6 presenter.fetchUser(userId); 7 } 8 9 @Override 10 public void showName(String name) { 11 mTextView.setText(name); 12 } 13 14 @Override 15 public void showError(...) { ... } 16 } ೖྗΛड͚औΔ 7JFXͷߋ৽ 6TFS"DUJWJUZ
  83. 1 public class UserActivity extends AppCompatActivity implements UserView { 2

    @Override 3 protected void onCreate(Bundle savedInstanceState) { 4 int userId = ...; 5 UserPresenter presenter = new UserPresenter(this); 6 presenter.fetchUser(userId); 7 } 8 9 @Override 10 public void showName(String name) { 11 mTextView.setText(name); 12 } 13 14 @Override 15 public void showError(...) { ... } 16 } ೖྗΛड͚औΔ 6TFS"DUJWJUZ
  84. 1 public class UserPresenter { 2 UserView mView; 3 4

    public UserPresenter(UserView view) { 5 mView = view; 6 } 7 8 public void fetchUser(int userId) { 9 UserService service = ApiClient.getInstance().create(UsersService.class); 10 service.fetch(userId, new Callback<User>() { 11 @Override 12 public void success(User user, Response response) { 13 mView.showName(user.getName()); 14 } 15 16 @Override 17 public void failure(RetrofitError error) { 18 mView.showError(error); 19 } 20 }); 21 } 22 } 6TFS1SFTFOUFS ϓϨθϯςʔγϣϯϩδοΫ
  85. 1 public class UserPresenter { 2 UserView mView; 3 4

    public UserPresenter(UserView view) { 5 mView = view; 6 } 7 8 public void fetchUser(int userId) { 9 UserService service = ApiClient.getInstance().create(UsersService.class); 10 service.fetch(userId, new Callback<User>() { 11 @Override 12 public void success(User user, Response response) { 13 mView.showName(user.getName()); 14 } 15 16 @Override 17 public void failure(RetrofitError error) { 18 mView.showError(error); 19 } 20 }); 21 } 22 } 6TFS1SFTFOUFS 6TFS7JFXJOUFSGBDFΛܦ༝ͯ͠7JFXͷߋ৽
  86. 1 public class UserActivity extends AppCompatActivity implements UserView { 2

    @Override 3 protected void onCreate(Bundle savedInstanceState) { 4 int userId = ...; 5 UserPresenter presenter = new UserPresenter(this); 6 presenter.fetchUser(userId); 7 } 8 9 @Override 10 public void showName(String name) { 11 mTextView.setText(name); 12 } 13 14 @Override 15 public void showError(...) { ... } 16 } 7JFXͷߋ৽ 6TFS"DUJWJUZ
  87. .71͸7JFX͔Β ϓϨθϯςʔγϣϯϩδοΫΛ෼཭ग़དྷΔ

  88. ͜ΕͰϓϨθϯςʔγϣϯϩδοΫͷςε τ͕୯ମςετͰॻ͚Δͧʙ

  89. Ͳ͏͍͏ςετʹͳΔͷ͔

  90. 1 public class UserPresenterTest { 2 @Test 3 public void

    testFetchUser() throws Exception { 4 final AtomicBoolean called = new AtomicBoolean(); 5 mMockClient.mock("/v4/users/1.json").to(200, "user.json"); 6 7 class MockedView implements UserView { 8 @Override 9 public void showName(String name) { 10 called.set(true); 11 assertThat(name).isEqualTo("hisaichi5518"); 12 } 13 } 14 15 UserPresenter presenter = new UserPresenter(new MockedView()); 16 presenter.fetchUser(1); 17 assertThat(called.get()).isEqualTo(true); 18 } 19 } 7JFXͷߋ৽͸ JOUFSGBDFΛܦ༝ͯ͠ߦ͏
  91. 1 public class UserPresenterTest { 2 @Test 3 public void

    testFetchUser() throws Exception { 4 final AtomicBoolean called = new AtomicBoolean(); 5 mMockClient.mock("/v4/users/1.json").to(200, "user.json"); 6 7 class MockedView implements UserView { 8 @Override 9 public void showName(String name) { 10 called.set(true); 11 assertThat(name).isEqualTo("hisaichi5518"); 12 } 13 } 14 15 UserPresenter presenter = new UserPresenter(new MockedView()); 16 presenter.fetchUser(1); 17 assertThat(called.get()).isEqualTo(true); 18 } 19 } JOUFSGBDFΛܧঝ͍ͯ͠Δ 7JFX΋Ͳ͖͑͋͞Ε͹ 1SFTFOUFSͷςετ͸Ͱ͖Δ
  92. 1 public class UserPresenterTest { 2 @Test 3 public void

    testFetchUser() throws Exception { 4 final AtomicBoolean called = new AtomicBoolean(); 5 mMockClient.mock("/v4/users/1.json").to(200, "user.json"); 6 7 class MockedView implements UserView { 8 @Override 9 public void showName(String name) { 10 called.set(true); 11 assertThat(name).isEqualTo("hisaichi5518"); 12 } 13 } 14 15 UserPresenter presenter = new UserPresenter(new MockedView()); 16 presenter.fetchUser(1); 17 assertThat(called.get()).isEqualTo(true); 18 } 19 } 7JFX΋Ͳ͖
  93. 1 public class UserPresenterTest { 2 @Test 3 public void

    testFetchUser() throws Exception { 4 final AtomicBoolean called = new AtomicBoolean(); 5 mMockClient.mock("/v4/users/1.json").to(200, "user.json"); 6 7 class MockedView implements UserView { 8 @Override 9 public void showName(String name) { 10 called.set(true); 11 assertThat(name).isEqualTo("hisaichi5518"); 12 } 13 } 14 15 UserPresenter presenter = new UserPresenter(new MockedView()); 16 presenter.fetchUser(1); 17 assertThat(called.get()).isEqualTo(true); 18 } 19 }
  94. 1 public class UserPresenterTest { 2 @Test 3 public void

    testFetchUser() throws Exception { 4 final AtomicBoolean called = new AtomicBoolean(); 5 mMockClient.mock("/v4/users/1.json").to(200, "user.json"); 6 7 class MockedView implements UserView { 8 @Override 9 public void showName(String name) { 10 called.set(true); 11 assertThat(name).isEqualTo("hisaichi5518"); 12 } 13 } 14 15 UserPresenter presenter = new UserPresenter(new MockedView()); 16 presenter.fetchUser(1); 17 assertThat(called.get()).isEqualTo(true); 18 } 19 }
  95. None
  96. .71ಋೖͷਐΊํ

  97. .71ಋೖ࣌ͷਐΊํ wཧ૝ɿςετΛॻ͍͔ͯΒϦϑΝΫλϦϯά͍ͯ͘͠ wݱ࣮ɿϦϑΝΫλϦϯάͱҰॹʹςετΛॻ͘ wಋೖ͸ɺݴ͍ग़ͬ͠΃ͷࣗ෼͕΍ͬͨ w౓ಋೖޙ͸ɺνʔϜϝϯόʔ͕֤ʑ.71ΞʔΩςΫ νϟʹԊ࣮ͬͯ૷ΛਐΊΔ

  98. ଞʹ΋΍ͬͨ͜ͱ

  99. ଞʹ΋΍ͬͨ͜ͱ wνʔϜϝϯόʔʹ.71ΞʔΩςΫνϟʹ͍ͭͯڞ༗ wIUUQIJTBJDIJIBUFOBCMPHKQFOUSZ  wςετͰ։ൃ"1*Λୟ͘Θ͚ʹ͸͍͔ͳ͍ͷͰ .PDL$MJFOUͷ࡞੒ wIUUQIJTBJDIJIBUFOBCMPHKQFOUSZ 

  100. ଞʹ΋΍ͬͨ͜ͱ w.71ΞʔΩςΫνϟͷαϯϓϧΞϓϦ࡞੒ w3PCPMFDUSJD(SBEMF5FTU3VOOFSΛܧঝͨ͠ 5FTU3VOOFSΛࣗ࡞ wϒϥϯνຖʹ$*্Ͱ୯ମςετΛ࣮ߦ͢ΔΑ͏ʹ͠ ͯɺͦͷςετ͕௨Βͳ͍ͱϚʔδ͠ͳ͍ϧʔϧ w%FWJDF'BSNΛ࣮ߦ͢Δϒϥϯν͸ϦϦʔεϒϥϯν ౳ʹߜͬͨ

  101. .71Ͱ΍ͬͯͳ͍͜ͱ

  102. .71Ͱ΍ͬͯͳ͍͜ͱ w1SFTFOUFSͷ࢖͍ճ͠ wͭͷ7JFXʹෳ਺ͷ1SFTFOUFSΛ࣋ͨͤΔ

  103. ͳͥɺ1SFTFOUFSΛ࢖͍·Θ͞ͳ͍ͷ͔ w1SFTFOUFS͸ɺ7JFXͷৼΔ෣͍ w7JFX͕ҧ͏ͱ͍͏͜ͱ͸ɺৼΔ෣͍΋ҧ͏

  104. ͳͥɺͭͷ7JFXʹͭͷ1SFTFOUFSʹ͢Δͷ͔ wͭͷ7JFXͷதͰʮϢʔβʔ৘ใऔಘͷৼΔ෣͍ʯʮ࡞ ඼৘ใऔಘͷৼΔ෣͍ʯͱ͍͏Α͏ͳୟ͘"1*͝ͱʹ 1SFTFOUFSΛ෼͚ͨΓ͠ͳ͍ w1SFTFOUFS͸7JFXͷৼΔ෣͍ͳͷͰద੾ʹ໾ׂ෼୲ ͕ग़དྷ͍ͯΔͷͰ͋Ε͹ɺͭͰे෼ͳ͸ͣ

  105. 1SFTFOUFS΁ͷ੾Γग़͠΋ਐΈ ୯ମςετ΋૿͖͑ͯͯॱௐ

  106. ໰୊ൃੜ

  107. ͭͷ1SFTFOUFS͕ େ͖͍Α໰୊

  108. ΍ͬͯͳ͍͜ͱͷͭ ͭͷ7JFXʹෳ਺ͷ1SFTFOUFS Λ࣋ͨͤΔ

  109. ྫ ੺࿮͕ͭͷ'SBHNFOU 7JFX  ͜ͷ7JFXʹ͸ɺ໾ׂ͕ͭ͋ Δɻ

  110. ྫ  ͓ؾʹೖΓొ࿥ɾղআ  ࡞඼৘ใදࣔ  ࡞඼ͷҰཡऔಘɾදࣔ   

  111. ͭͷ1SFTFOUFS͕େ͖͍໰୊Λ ղܾ͢ΔͨΊʹ΍ͬͨ͜ͱ

  112. ໾ׂ͝ͱʹ $VTUPN7JFXʹ੾Γ෼͚Δ

  113. ྫ  ͓ؾʹೖΓొ࿥ɾղআ  ࡞඼৘ใදࣔ  ࡞඼ͷҰཡऔಘɾදࣔ   

  114. େ͖ͳ1SFTFOUFSΛ෼ׂͰ͖ͨ

  115. ͜Μͳײ͡Ͱ ϦϑΝΫλϦϯάਐΊ͍ͯ·͢

  116. ·ͱΊ

  117. ·ͱΊ w6*ςετΛ૿΍ͦ͏ͱࣦͯ͠ഊ w୯ମςετ͕ॻ͚ͳ͍ͷ͸ͭͷΫϥεʹ٧ΊࠐΈա ͍͗ͯΔ͔Β wͭͷΫϥεʹ٧ΊࠐΈա͗Δͷ͸ɺܾ·Γࣄ͕ͳ͍ ͔Β wܾ·Γࣄͱ͸ɺΞʔΩςΫνϟ

  118. ·ͱΊ wΞʔΩςΫνϟʹ͸.71Λ࠾༻ w.7$͸"OESPJEͩͱ੹຿ͷ෼཭͕Ͱ͖ͳ͍ w.71͸7JFX͔ΒϓϨθϯςʔγϣϯϩδοΫΛ෼཭ Ͱ͖Δ w7JFXͷ໾ׂ͕େ͖͍ͱ1SFTFOUFS͕େ͖͘ͳͬͯ͠ ·͏ͷͰɺ$VTUPN7JFXʹ੾Γग़ͯ͠খ͘͢͞Δ

  119. Ұॹʹಇ͍ͯ͘Εʙʙʙ ࠷৽ͷ࠾༻৘ใΛνΣοΫˠ !QC@SFDSVJU

  120. ͕࣌ؒ ༨Ε͹

  121. ։ൃ εϐʔυ

  122. ʹ͍ͭͯ

  123. l៉ྷͳίʔυΑΓ։ൃεϐʔυ༏ઌz

  124. ͱ͍͏͜ͱ͸ w៉ྷͳίʔυ͸ɺ։ൃεϐʔυͱ൓ൺྫ͢Δ

  125. ͳΔ΄Ͳ

  126. ๻͸͜͏ࢥ͏οε w៉ྷͳίʔυΛॻ͍ͯ΋ɺ։ൃεϐʔυ͕མͪͳ͍ w៉ྷͳίʔυ͸ɺ։ൃεϐʔυͱൺྫ͢Δ

  127. ͳ͔ͥ w៉ྷͳίʔυͱ͸ɺมԽʹڧ͍ίʔυ wมԽʹڧ͍ίʔυ͸ߴ଎ʹมԽग़དྷΔͷͰɺ։ൃεϐʔ υ͸ૣ͍͸ͣ

  128. มԽʹڧ͍ʢ͓͞Β͍ʣ wมԽʹڧ͍ͱ͸ɺʮίʔυͷཧղ͕͠΍͍͢ʯʮมߋ ΛՃ͑΍͍͢ʯʮՃ͑ͨมߋͷӨڹΛཧղ͠΍͍͢ʯ Λࢦ͢

  129. ࣮ࡍͲ͏ͩͬͨͷ͔  νʔϜϝϯόʔʹฉ͍ͯΈͨ

  130. .71ΞʔΩςΫνϟΛ͍ΕͯΈͯ ։ൃεϐʔυ͸མͪ·ͨ͠

  131. νʔϜϝϯόʔʹฉ͍ͯΈͨ wʮ.71ΞʔΩςΫνϟͰճ͘Β͍ॻ͘·Ͱ׳Εͳ ͔ͬͨʯ wʮ׳Εͨ͋ͱ͸ɺϩδοΫͷ৔ॴͱ͔͕୳͠΍͘͢ͳͬ ͯɺঃʑʹ։ൃ͕࣌ؒ୹͘ͳ͍ͬͯΔΑ͏ʹײͨ͡ʯ

  132. ͭ·Γ w୹ظతʹݟΕ͹ɺ׳ΕΔ·Ͱʹ͕͔͔࣌ؒΔͷͰ։ൃ εϐʔυ͸Լ͕Δ wத௕ظతʹݟΕ͹ɺมԽʹڧ͍ίʔυʹͳ͍ͬͯͬͯ ΔͷͰɺ։ൃεϐʔυ͸্͕͍ͬͯ͘

  133. ͲͪΒͷࢹ఺ͰݟΔ͔͸ ͋ͳͨ࣍ୈ

  134. Ұॹʹಇ͍ͯ͘Εʙʙʙ ࠷৽ͷ࠾༻৘ใΛνΣοΫˠ !QC@SFDSVJU