Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
dagger2
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
funnelbit
April 20, 2015
570
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
dagger2
funnelbit
April 20, 2015
More Decks by funnelbit
See All by funnelbit
Hatena Engineer Seminar #9
funnelbit
5
7.5k
droidkaigi-2017-renovation
funnelbit
10
11k
Dart
funnelbit
0
310
BottomBarAndSnackBar
funnelbit
0
560
Dagger2 Optional bindings
funnelbit
0
620
WearableRecyclerView
funnelbit
1
860
QucikSettingsTileAPI
funnelbit
0
390
Mobile Vision
funnelbit
0
500
AwarenessAPI
funnelbit
0
170
Featured
See All Featured
Raft: Consensus for Rubyists
vanstee
142
7.8k
Music & Morning Musume
bryan
48
7.4k
What does AI have to do with Human Rights?
axbom
PRO
1
2.5k
Speed Design
sergeychernyshev
33
2.2k
Agile that works and the tools we love
rasmusluckow
331
22k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
31k
Fantastic passwords and where to find them - at NoRuKo
philnash
53
4k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
850
How to Think Like a Performance Engineer
csswizardry
28
2.9k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
430
Exploring anti-patterns in Rails
aemeredith
4
540
Test your architecture with Archunit
thirion
2
2.4k
Transcript
%BHHFS JEGVOOFMCJU
ࣗݾհ w JEGVOOFMCJU ଜɹྋ w גࣜձࣾͯͳ w ΞϓϦέʔγϣϯΤϯδχΞ w
ڈ͔ΒΞϓϦ։ൃΛ࢝Ίͨ
%BHHFS
%BHHFS w IUUQTHJUIVCDPNHPPHMFEBHHFS w %*ίϯςφ w 4RVBSF͕։ൃͯͨ͠%BHHFSͷHPPHMFGPSL w ਖ਼ࣜ൛ ͍ͭઌϦϦʔε
w ։ൃ൛ͷ4/"14)05
%BHHFSͷϝϦοτ w ίϯύΠϧ࣌ʹίʔυੜ͠ґଘղܾ w KBWBYJOKFDU"OOPUBUJPOΛ༻ w ։ൃ͕׆ൃ
%BHHFS ༻ྫ
ߏΠϝʔδ .PEVMF &OUSZ.BOBHFS "DUJWJUZ &OUSZ.BOBHFS "QQMJDBUJPO $PNQPOFOU "1*$MJFOU
௨৴෦ 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); } …
.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); } … ௨৴෦
$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; } }
%BHHFS ༻ྫ ςετ
.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
௨৴෦ʢςετʣ @Override public BkumaService getService() { RestAdapter restAdapter = new
RestAdapter .Builder() .setEndpoint(BkumaService.END_POINT) .build(); MockRestAdapter mockRestAdapter = MockRestAdapter.from(restAdapter); mockRestAdapter.setDelay(0); …(ଓ͖·͢) 5FTU༻.PDL
௨৴෦ʢςετʣ … BkumaService bkumaService = new BkumaService() { @Override public
void getTopEntries(@Query("limit") int limit, Callback<List<EntryResponse>> callback) { callback.success( TestUtils.createDummyEntry(mContext, limit), createDummyJsonResponse() ); } }); return mockRestAdapter.create( BkumaService.class, bkumaService ); %VNNZ 3FTQPOTF
*OKFDU ςετ public class BkumaEntryManagerTest extends InstrumentationTestCase { … @Inject
EntryManager mEntryManager; … public testGetEntries() { assertEquals( "ΤϯτϦऔಘͰ͖͍ͯΔ", false, mEntryManager.getEntries().isEmpty()); } }
·ͱΊ w ςελϒϧͳίʔυ͕࡞Γ͍͢ w *OTUBODFཧ͕͘͢͠ͳΔ w "DUJWJUZͷ࠶ੜ࣌ͳͲʹޮ͍ͯ͘Δ
͋Γ͕ͱ͏͍͟͝·ͨ͠