Slide 1

Slide 1 text

%BHHFS JEGVOOFMCJU

Slide 2

Slide 2 text

ࣗݾ঺հ w JEGVOOFMCJU ๺ଜɹྋ w גࣜձࣾ͸ͯͳ w ΞϓϦέʔγϣϯΤϯδχΞ w ڈ೥͔ΒΞϓϦ։ൃΛ࢝Ίͨ

Slide 3

Slide 3 text

%BHHFS

Slide 4

Slide 4 text

%BHHFS w IUUQTHJUIVCDPNHPPHMFEBHHFS w %*ίϯςφ w 4RVBSF͕։ൃͯͨ͠%BHHFSͷHPPHMFGPSL w ਖ਼ࣜ൛ ͍ͭઌ೔ϦϦʔε w ։ൃ൛ͷ4/"14)05

Slide 5

Slide 5 text

%BHHFSͷϝϦοτ w ίϯύΠϧ࣌ʹίʔυੜ੒͠ґଘղܾ w KBWBYJOKFDU"OOPUBUJPOΛ࢖༻ w ։ൃ͕׆ൃ

Slide 6

Slide 6 text

%BHHFS ࢖༻ྫ

Slide 7

Slide 7 text

ߏ੒Πϝʔδ .PEVMF &OUSZ.BOBHFS "DUJWJUZ &OUSZ.BOBHFS "QQMJDBUJPO $PNQPOFOU "1*$MJFOU

Slide 8

Slide 8 text

௨৴෦෼ public class BkumaFormalServiceProvider implements BkumaServiceProvider {
 …
 @Override
 public BkumaService getService() {
 OkHttpClient client = new OkHttpClient();
 
 RestAdapter restAdapter = new RestAdapter.Builder()
 .setClient(new OkClient(client))
 .setEndpoint(BkumaService.END_POINT)
 .build();
 return restAdapter.create(BkumaService.class);
 } …

Slide 9

Slide 9 text

.PEVMF͔Β*OKFDU @Module
 public class BkumaModule {
 private final BkumaService mBkumaService;
 public BkumaModule(BkumaGirlsApplication application) {
 mBkumaService = new BkumaFormalServiceProvider(application .getApplicationContext()).getService();
 
 @Provides @Singleton
 EntryManager provideEntryManager() {
 return new EntryManager(mBkumaService);
 } … public class MainActivity extends ActionBarActivity { @Inject EntryManager mEntryManager; @Override
 protected void onCreate(Bundle savedInstanceState) {
 … ((BkumaGirlsApplication)getApplication()).component() .inject(this); } … ௨৴෦෼

Slide 10

Slide 10 text

$PNQPOFOUΛ࡞Δ public class BKUMAGirlsApplication extends Application {
 @Singleton
 @Component(modules = BkumaModule.class)
 public interface ApplicationComponent {
 void inject(MainActivity mainActivity);
 }
 
 private ApplicationComponent mComponent;
 
 @Override
 public void onCreate() {
 mComponent = DaggerBKUMAGirlsApplication_ApplicationComponent.builder()
 .bkumaModule(new BkumaModule(this))
 .build();
 }
 
 public ApplicationComponent component() {
 return mComponent;
 }
 }

Slide 11

Slide 11 text

%BHHFS ࢖༻ྫ ςετ

Slide 12

Slide 12 text

.PEVMF ςετ @Module
 public class BkumaTestModule {
 private final BkumaService mBkumaService; …
 public BkumaTestModule(InstrumentationTestCase instrumentationTestCase) { mBkumaService = new BkumaMockServiceProvider(mInstrumentationTestCase .getInstrumentation().getContext()).getService();
 }
 
 @Provides
 EntryManager provideEntryManager() {
 return new EntryManager(mBkumaService);
 } … 5FTU༻ #LVNB4FSWJDF

Slide 13

Slide 13 text

௨৴෦෼ʢςετʣ @Override
 public BkumaService getService() {
 RestAdapter restAdapter = new RestAdapter
 .Builder()
 .setEndpoint(BkumaService.END_POINT)
 .build();
 
 MockRestAdapter mockRestAdapter = MockRestAdapter.from(restAdapter);
 mockRestAdapter.setDelay(0); …(ଓ͖·͢) 5FTU༻.PDL

Slide 14

Slide 14 text

௨৴෦෼ʢςετʣ …
 BkumaService bkumaService = new BkumaService() {
 @Override
 public void getTopEntries(@Query("limit") int limit, Callback> callback) {
 callback.success( TestUtils.createDummyEntry(mContext, limit),
 createDummyJsonResponse()
 );
 } }); return mockRestAdapter.create( BkumaService.class, bkumaService ); %VNNZ 3FTQPOTF

Slide 15

Slide 15 text

*OKFDU ςετ public class BkumaEntryManagerTest extends InstrumentationTestCase {
 …
 @Inject
 EntryManager mEntryManager;
 … public testGetEntries() { assertEquals( "ΤϯτϦऔಘͰ͖͍ͯΔ", false, mEntryManager.getEntries().isEmpty()); }
 }

Slide 16

Slide 16 text

·ͱΊ w ςελϒϧͳίʔυ͕࡞Γ΍͍͢ w *OTUBODF؅ཧ͕͠΍͘͢ͳΔ w "DUJWJUZͷ࠶ੜ੒࣌ͳͲʹޮ͍ͯ͘Δ

Slide 17

Slide 17 text

͋Γ͕ͱ͏͍͟͝·ͨ͠