Share
Embed
Transcript
108 slides
-
ࣗݾհ • ւ౻༏ʢ͔͍Ͳ͏Ώ͏ʣ • גࣜձࣾΤϨΧ • ςετॻ͚ॻ͚͓͡͞Μʢ৽ଔʣ • Android2
yuyakaido yuyakaido -
גࣜձࣾΤϨΧ • ࣗࣾαʔϏεͷاըɾ։ൃɾӡӦ • ΦϯϥΠϯσʔςΟϯάαʔϏεɿ • Χοϓϧઐ༻ΞϓϦɿ • ࣾһɿ85໊ •
IACάϧʔϓ ΤϯδχΞ 55 ඇΤϯδχΞ 30 -
࣍ • ςετ͕ͳ͍ͱͲ͏ਏ͍ͷ͔ • Couplesͷઃܭ • ςελϏϦςΟͷߴ͍ઃܭ • ςετख๏ɾϑϨʔϜϫʔΫ •
αϯϓϧΞϓϦͰͷςετ • ςετΛॻ͘จԽΛ࡞ΔͨΊʹ • ·ͱΊ -
࣍ • ςετ͕ͳ͍ͱͲ͏ਏ͍ͷ͔ • Couplesͷઃܭ • ςελϏϦςΟͷߴ͍ઃܭ • ςετख๏ɾϑϨʔϜϫʔΫ •
αϯϓϧΞϓϦͰͷςετ • ςετΛॻ͘จԽΛ࡞ΔͨΊʹ • ·ͱΊ -
ͦΕͧΕͷ • େͳςετέʔεͷਓྗ֬ೝ • ਓతϦιʔεͷ࿘අ → ػձଛࣦ • ӨڹൣғͷߟྀϛεʹΑΔόά •
Ϣʔβʔͷ → ػձଛࣦ • ςετέʔεͷෳࡶԽ • ਓతϦιʔεͷ࿘අ → ػձଛࣦ -
࣍ • ςετ͕ͳ͍ͱͲ͏ਏ͍ͷ͔ • Couplesͷઃܭ • ςελϏϦςΟͷߴ͍ઃܭ • ςετख๏ɾϑϨʔϜϫʔΫ •
αϯϓϧΞϓϦͰͷςετ • ςετΛॻ͘จԽΛ࡞ΔͨΊʹ • ·ͱΊ -
ݱঢ়ͷઃܭ • ϚονϣͳActivity/Fragment • ຊʹͼͬ͘Γ͢Δ͘Β͍Ϛονϣ • ςετ͕ॻ͚ͳ͍Ͳ͜Ζ͔ػೳՃਏ͍ • όοΫΤϯυͷΫϥεؒͷґଘ͕ؔෳࡶ •
ςετ͕ॻ͖ʹ͍͘ • ϞοΫαʔόʔͷࠩ͠ସ͕͍͑͠ -
͓͡͞Μͷܾஅ • طଘͷόοΫΤϯυʹखΛೖΕΔ • ґଘ͕ؔෳࡶ • ςετ͕ͳ͍ঢ়ଶͰखΛೖΕΔͷ͕ා͍ • ৽͍͠όοΫΤϯυΛ࡞ͬͯΓ͑ •
ґଘؔΛ៉ྷʹཧ • ςετΛॻ͖ͳ͕Βػೳ୯ҐͰॱ࣍ஔ͖͑Δ͜ͱ ͰϦεΫΛԼ͛Δ -
࣍ • ςετ͕ͳ͍ͱͲ͏ਏ͍ͷ͔ • Couplesͷઃܭ • ςελϏϦςΟͷߴ͍ઃܭ • ςετख๏ɾϑϨʔϜϫʔΫ •
αϯϓϧΞϓϦͰͷςετ • ςετΛॻ͘จԽΛ࡞ΔͨΊʹ • ·ͱΊ -
όοΫΤϯυ Repository Database Network DB Server ActiveAndroid Retrofit ×
OkHttp Observable<T> Observable<T> -
MVP • ϝϦοτ • ͷ • Activity/Fragment = View •
Presenter = Controller • σϝϦοτ • Ϋϥε͕ଟ͘ͳΔ • νʔϜ։ൃͷ߹͋ΔఔυΩϡϝϯτ͕ඞཁ -
࣍ • ςετ͕ͳ͍ͱͲ͏ਏ͍ͷ͔ • Couplesͷઃܭ • ςελϏϦςΟͷߴ͍ઃܭ • ςετख๏ɾϑϨʔϜϫʔΫ •
αϯϓϧΞϓϦͰͷςετ • ςετΛॻ͘จԽΛ࡞ΔͨΊʹ • ·ͱΊ -
Espresso • Testing Support Library • UIͷಈؚ͖Ίͨςετ͕ॻ͚Δ • ࣮ػ্Ͱςετ࣮ߦ •
ਓ͕ؒૢ࡞͢Δͷͱಉ༷ͷ͕͔͔࣌ؒΔ -
࣍ • ςετ͕ͳ͍ͱͲ͏ਏ͍ͷ͔ • Couplesͷઃܭ • ςελϏϦςΟͷߴ͍ઃܭ • ςετख๏ɾϑϨʔϜϫʔΫ •
αϯϓϧΞϓϦͰͷςετ • ςετΛॻ͘จԽΛ࡞ΔͨΊʹ • ·ͱΊ -
Contributor @Table public class Contributor { @Column(unique = true,
uniqueOnConflict = OnConflict.REPLACE) @SerializedName("login") public String login; @Column @Nullable @SerializedName("avatar_url") public String avatarUrl; @Column @Nullable @SerializedName("html_url") public String htmlUrl; @Column @SerializedName("contributions") public int contributions; } -
GithubNetwork public String getBaseUrl() { return "https://api.github.com"; } public
Observable<List<Contributor>> getContributors(String owner, String repo) { GithubApi githubApi = ApiClientGenerater.generate(GithubApi.class, getBaseUrl()); return githubApi.getContributors(owner, repo) .map(new Func1<List<Contributor>, List<Contributor>>() { @Override public List<Contributor> call(List<Contributor> contributors) { Database.getDatabase() .prepareInsertIntoContributor() .executeAll(contributors); return contributors; } }); } public Observable<List<Contributor>> getContributors() { return getContributors("konifar", "droidkaigi2016"); } -
GithubNetwork public String getBaseUrl() { return "https://api.github.com"; } public
Observable<List<Contributor>> getContributors(String owner, String repo) { GithubApi githubApi = ApiClientGenerater.generate(GithubApi.class, getBaseUrl()); return githubApi.getContributors(owner, repo) .map(new Func1<List<Contributor>, List<Contributor>>() { @Override public List<Contributor> call(List<Contributor> contributors) { Database.getDatabase() .prepareInsertIntoContributor() .executeAll(contributors); return contributors; } }); } public Observable<List<Contributor>> getContributors() { return getContributors("konifar", "droidkaigi2016"); } -
GithubNetwork public String getBaseUrl() { return "https://api.github.com"; } public
Observable<List<Contributor>> getContributors(String owner, String repo) { GithubApi githubApi = ApiClientGenerater.generate(GithubApi.class, getBaseUrl()); return githubApi.getContributors(owner, repo) .map(new Func1<List<Contributor>, List<Contributor>>() { @Override public List<Contributor> call(List<Contributor> contributors) { Database.getDatabase() .prepareInsertIntoContributor() .executeAll(contributors); return contributors; } }); } public Observable<List<Contributor>> getContributors() { return getContributors("konifar", "droidkaigi2016"); } -
GithubNetwork public String getBaseUrl() { return "https://api.github.com"; } public
Observable<List<Contributor>> getContributors(String owner, String repo) { GithubApi githubApi = ApiClientGenerater.generate(GithubApi.class, getBaseUrl()); return githubApi.getContributors(owner, repo) .map(new Func1<List<Contributor>, List<Contributor>>() { @Override public List<Contributor> call(List<Contributor> contributors) { Database.getDatabase() .prepareInsertIntoContributor() .executeAll(contributors); return contributors; } }); } public Observable<List<Contributor>> getContributors() { return getContributors("konifar", "droidkaigi2016"); } -
GithubNetwork public String getBaseUrl() { return "https://api.github.com"; } public
Observable<List<Contributor>> getContributors(String owner, String repo) { GithubApi githubApi = ApiClientGenerater.generate(GithubApi.class, getBaseUrl()); return githubApi.getContributors(owner, repo) .map(new Func1<List<Contributor>, List<Contributor>>() { @Override public List<Contributor> call(List<Contributor> contributors) { Database.getDatabase() .prepareInsertIntoContributor() .executeAll(contributors); return contributors; } }); } public Observable<List<Contributor>> getContributors() { return getContributors("konifar", "droidkaigi2016"); } -
GithubNetwork public String getBaseUrl() { return "https://api.github.com"; } public
Observable<List<Contributor>> getContributors(String owner, String repo) { GithubApi githubApi = ApiClientGenerater.generate(GithubApi.class, getBaseUrl()); return githubApi.getContributors(owner, repo) .map(new Func1<List<Contributor>, List<Contributor>>() { @Override public List<Contributor> call(List<Contributor> contributors) { Database.getDatabase() .prepareInsertIntoContributor() .executeAll(contributors); return contributors; } }); } public Observable<List<Contributor>> getContributors() { return getContributors("konifar", "droidkaigi2016"); } -
GithubNetwork public String getBaseUrl() { return "https://api.github.com"; } public
Observable<List<Contributor>> getContributors(String owner, String repo) { GithubApi githubApi = ApiClientGenerater.generate(GithubApi.class, getBaseUrl()); return githubApi.getContributors(owner, repo) .map(new Func1<List<Contributor>, List<Contributor>>() { @Override public List<Contributor> call(List<Contributor> contributors) { Database.getDatabase() .prepareInsertIntoContributor() .executeAll(contributors); return contributors; } }); } public Observable<List<Contributor>> getContributors() { return getContributors("konifar", "droidkaigi2016"); } -
GithubDatabaseͷςετ final int COUNT = 10; List<Contributor> contributors = new
ArrayList<>(COUNT); for (int i = 0; i < COUNT; i++) { Contributor contributor = new Contributor(); contributor.login = String.valueOf(i); contributor.avatarUrl = String.valueOf(i); contributor.htmlUrl = String.valueOf(i); contributor.contributions = i; contributors.add(contributor); } Database.getDatabase() .prepareInsertIntoContributor() .executeAll(contributors); TestSubscriber<List<Contributor>> testSubscriber = new TestSubscriber<>(); GithubDatabase.getContributors().subscribe(testSubscriber); testSubscriber.assertNoErrors(); testSubscriber.assertCompleted(); List<Contributor> result = testSubscriber.getOnNextEvents().get(0); assertThat(result.size(), is(contributors.size())); -
GithubDatabaseͷςετ final int COUNT = 10; List<Contributor> contributors = new
ArrayList<>(COUNT); for (int i = 0; i < COUNT; i++) { Contributor contributor = new Contributor(); contributor.login = String.valueOf(i); contributor.avatarUrl = String.valueOf(i); contributor.htmlUrl = String.valueOf(i); contributor.contributions = i; contributors.add(contributor); } Database.getDatabase() .prepareInsertIntoContributor() .executeAll(contributors); TestSubscriber<List<Contributor>> testSubscriber = new TestSubscriber<>(); GithubDatabase.getContributors().subscribe(testSubscriber); testSubscriber.assertNoErrors(); testSubscriber.assertCompleted(); List<Contributor> result = testSubscriber.getOnNextEvents().get(0); assertThat(result.size(), is(contributors.size())); -
TestSubscriber Integer[] integers = new Integer[] {1, 2, 3}; Observable<Integer>
observable = Observable.from(integers); observable.subscribe(new Subscriber<Integer>() { @Override public void onCompleted() {} @Override public void onError(Throwable e) {} @Override public void onNext(Integer integer) { throw new RuntimeException(); } }); -
TestSubscriber @Test public void subscriberTest() { Integer[] integers = new
Integer[] {1, 2, 3}; Observable<Integer> observable = Observable.from(integers); TestSubscriber<Integer> testSubscriber = new TestSubscriber<>(); observable.subscribe(testSubscriber); testSubscriber.assertNoErrors(); testSubscriber.assertValueCount(integers.length); testSubscriber.assertValues(integers); testSubscriber.assertCompleted(); } -
GithubDatabaseͷςετ final int COUNT = 10; List<Contributor> contributors = new
ArrayList<>(COUNT); for (int i = 0; i < COUNT; i++) { Contributor contributor = new Contributor(); contributor.login = String.valueOf(i); contributor.avatarUrl = String.valueOf(i); contributor.htmlUrl = String.valueOf(i); contributor.contributions = i; contributors.add(contributor); } Database.getDatabase() .prepareInsertIntoContributor() .executeAll(contributors); TestSubscriber<List<Contributor>> testSubscriber = new TestSubscriber<>(); GithubDatabase.getContributors().subscribe(testSubscriber); testSubscriber.assertNoErrors(); testSubscriber.assertCompleted(); List<Contributor> result = testSubscriber.getOnNextEvents().get(0); assertThat(result.size(), is(contributors.size())); -
GithubDatabaseͷςετ final int COUNT = 10; List<Contributor> contributors = new
ArrayList<>(COUNT); for (int i = 0; i < COUNT; i++) { Contributor contributor = new Contributor(); contributor.login = String.valueOf(i); contributor.avatarUrl = String.valueOf(i); contributor.htmlUrl = String.valueOf(i); contributor.contributions = i; contributors.add(contributor); } Database.getDatabase() .prepareInsertIntoContributor() .executeAll(contributors); TestSubscriber<List<Contributor>> testSubscriber = new TestSubscriber<>(); GithubDatabase.getContributors().subscribe(testSubscriber); testSubscriber.assertNoErrors(); testSubscriber.assertCompleted(); List<Contributor> result = testSubscriber.getOnNextEvents().get(0); assertThat(result.size(), is(contributors.size())); -
GithubDatabaseͷςετ final int COUNT = 10; List<Contributor> contributors = new
ArrayList<>(COUNT); for (int i = 0; i < COUNT; i++) { Contributor contributor = new Contributor(); contributor.login = String.valueOf(i); contributor.avatarUrl = String.valueOf(i); contributor.htmlUrl = String.valueOf(i); contributor.contributions = i; contributors.add(contributor); } Database.getDatabase() .prepareInsertIntoContributor() .executeAll(contributors); TestSubscriber<List<Contributor>> testSubscriber = new TestSubscriber<>(); GithubDatabase.getContributors().subscribe(testSubscriber); testSubscriber.assertNoErrors(); testSubscriber.assertCompleted(); List<Contributor> result = testSubscriber.getOnNextEvents().get(0); assertThat(result.size(), is(contributors.size())); -
GithubDatabaseͷςετ final int COUNT = 10; List<Contributor> contributors = new
ArrayList<>(COUNT); for (int i = 0; i < COUNT; i++) { Contributor contributor = new Contributor(); contributor.login = String.valueOf(i); contributor.avatarUrl = String.valueOf(i); contributor.htmlUrl = String.valueOf(i); contributor.contributions = i; contributors.add(contributor); } Database.getDatabase() .prepareInsertIntoContributor() .executeAll(contributors); TestSubscriber<List<Contributor>> testSubscriber = new TestSubscriber<>(); GithubDatabase.getContributors().subscribe(testSubscriber); testSubscriber.assertNoErrors(); testSubscriber.assertCompleted(); List<Contributor> result = testSubscriber.getOnNextEvents().get(0); assertThat(result.size(), is(contributors.size())); -
GithubNetworkͷςετ File file = new File("src/test/assets/json/github_contributors.json"); MockWebServer mockWebServer = new
MockWebServer(); mockWebServer.enqueue(ResponseUtil.createMockResponse(file)); mockWebServer.start(); GithubNetwork githubNetwork = GithubNetwork.getInstance(); githubNetwork = spy(githubNetwork); when(githubNetwork.getBaseUrl()) .thenReturn(mockWebServer.url("/").toString()); TestSubscriber<List<Contributor>> testSubscriber = new TestSubscriber<>(); githubNetwork.getContributors().subscribe(testSubscriber); testSubscriber.assertNoErrors(); testSubscriber.assertCompleted(); List<Contributor> contributors = testSubscriber.getOnNextEvents().get(0); assertThat(contributors.size(), is(1)); -
GithubNetworkͷςετ File file = new File("src/test/assets/json/github_contributors.json"); MockWebServer mockWebServer = new
MockWebServer(); mockWebServer.enqueue(ResponseUtil.createMockResponse(file)); mockWebServer.start(); GithubNetwork githubNetwork = GithubNetwork.getInstance(); githubNetwork = spy(githubNetwork); when(githubNetwork.getBaseUrl()) .thenReturn(mockWebServer.url("/").toString()); TestSubscriber<List<Contributor>> testSubscriber = new TestSubscriber<>(); githubNetwork.getContributors().subscribe(testSubscriber); testSubscriber.assertNoErrors(); testSubscriber.assertCompleted(); List<Contributor> contributors = testSubscriber.getOnNextEvents().get(0); assertThat(contributors.size(), is(1)); -
MockWebServer File file = new File( "src/test/assets/json/github_contributors.json"); MockWebServer mockWebServer =
new MockWebServer(); mockWebServer.enqueue(ResponseUtil.createMockResponse(file)); mockWebServer.start(); -
MockWebServer File file = new File( "src/test/assets/json/github_contributors.json"); MockWebServer mockWebServer =
new MockWebServer(); mockWebServer.enqueue(ResponseUtil.createMockResponse(file)); mockWebServer.start(); -
MockWebServer File file = new File( "src/test/assets/json/github_contributors.json"); MockWebServer mockWebServer =
new MockWebServer(); mockWebServer.enqueue(ResponseUtil.createMockResponse(file)); mockWebServer.start(); -
MockWebServer File file = new File( "src/test/assets/json/github_contributors.json"); MockWebServer mockWebServer =
new MockWebServer(); mockWebServer.enqueue(ResponseUtil.createMockResponse(file)); mockWebServer.start(); -
ϝιουͷݺͼग़֬͠ೝ // mock creation List mockedList = mock(List.class); //
using mock object - it does not throw any "unexpected interaction" exception mockedList.add("one"); mockedList.clear(); // selective, explicit, highly readable verification verify(mockedList).add("one"); verify(mockedList).clear(); -
ϝιουͷݺͼग़֬͠ೝ // mock creation List mockedList = mock(List.class); //
using mock object - it does not throw any "unexpected interaction" exception mockedList.add("one"); mockedList.clear(); // selective, explicit, highly readable verification verify(mockedList).add("one"); verify(mockedList).clear(); -
ϝιουͷݺͼग़֬͠ೝ // mock creation List mockedList = mock(List.class); //
using mock object - it does not throw any "unexpected interaction" exception mockedList.add("one"); mockedList.clear(); // selective, explicit, highly readable verification verify(mockedList).add("one"); verify(mockedList).clear(); -
ϝιουͷݺͼग़֬͠ೝ // mock creation List mockedList = mock(List.class); //
using mock object - it does not throw any "unexpected interaction" exception mockedList.add("one"); mockedList.clear(); // selective, explicit, highly readable verification verify(mockedList).add("one"); verify(mockedList).clear(); -
ϝιουͷฦͷϞοΫ // you can mock concrete classes, not only interfaces
LinkedList mockedList = mock(LinkedList.class); // stubbing appears before the actual execution when(mockedList.get(0)).thenReturn("first"); // the following is "first" assertThat((String) mockedList.get(0), is("first")); // the following is "null" because get(999) was not stubbed assertThat(mockedList.get(999), nullValue()); -
ϝιουͷฦͷϞοΫ // you can mock concrete classes, not only interfaces
LinkedList mockedList = mock(LinkedList.class); // stubbing appears before the actual execution when(mockedList.get(0)).thenReturn("first"); // the following is "first" assertThat((String) mockedList.get(0), is("first")); // the following is "null" because get(999) was not stubbed assertThat(mockedList.get(999), nullValue()); -
ϝιουͷฦͷϞοΫ // you can mock concrete classes, not only interfaces
LinkedList mockedList = mock(LinkedList.class); // stubbing appears before the actual execution when(mockedList.get(0)).thenReturn("first"); // the following is "first" assertThat((String) mockedList.get(0), is("first")); // the following is "null" because get(999) was not stubbed assertThat(mockedList.get(999), nullValue()); -
ϝιουͷฦͷϞοΫ // you can mock concrete classes, not only interfaces
LinkedList mockedList = mock(LinkedList.class); // stubbing appears before the actual execution when(mockedList.get(0)).thenReturn("first"); // the following is "first" assertThat((String) mockedList.get(0), is("first")); // the following is "null" because get(999) was not stubbed assertThat(mockedList.get(999), nullValue()); -
ϝιουͷฦͷϞοΫ // you can mock concrete classes, not only interfaces
LinkedList mockedList = mock(LinkedList.class); // stubbing appears before the actual execution when(mockedList.get(0)).thenReturn("first"); // the following is "first" assertThat((String) mockedList.get(0), is("first")); // the following is "null" because get(999) was not stubbed assertThat(mockedList.get(999), nullValue()); -
GithubNetworkͷςετ File file = new File("src/test/assets/json/github_contributors.json"); MockWebServer mockWebServer = new
MockWebServer(); mockWebServer.enqueue(ResponseUtil.createMockResponse(file)); mockWebServer.start(); GithubNetwork githubNetwork = GithubNetwork.getInstance(); githubNetwork = spy(githubNetwork); when(githubNetwork.getBaseUrl()) .thenReturn(mockWebServer.url("/").toString()); TestSubscriber<List<Contributor>> testSubscriber = new TestSubscriber<>(); githubNetwork.getContributors().subscribe(testSubscriber); testSubscriber.assertNoErrors(); testSubscriber.assertCompleted(); List<Contributor> contributors = testSubscriber.getOnNextEvents().get(0); assertThat(contributors.size(), is(1)); -
GithubNetworkͷςετ File file = new File("src/test/assets/json/github_contributors.json"); MockWebServer mockWebServer = new
MockWebServer(); mockWebServer.enqueue(ResponseUtil.createMockResponse(file)); mockWebServer.start(); GithubNetwork githubNetwork = GithubNetwork.getInstance(); githubNetwork = spy(githubNetwork); when(githubNetwork.getBaseUrl()) .thenReturn(mockWebServer.url("/").toString()); TestSubscriber<List<Contributor>> testSubscriber = new TestSubscriber<>(); githubNetwork.getContributors().subscribe(testSubscriber); testSubscriber.assertNoErrors(); testSubscriber.assertCompleted(); List<Contributor> contributors = testSubscriber.getOnNextEvents().get(0); assertThat(contributors.size(), is(1)); -
GithubNetworkͷςετ File file = new File("src/test/assets/json/github_contributors.json"); MockWebServer mockWebServer = new
MockWebServer(); mockWebServer.enqueue(ResponseUtil.createMockResponse(file)); mockWebServer.start(); GithubNetwork githubNetwork = GithubNetwork.getInstance(); githubNetwork = spy(githubNetwork); when(githubNetwork.getBaseUrl()) .thenReturn(mockWebServer.url("/").toString()); TestSubscriber<List<Contributor>> testSubscriber = new TestSubscriber<>(); githubNetwork.getContributors().subscribe(testSubscriber); testSubscriber.assertNoErrors(); testSubscriber.assertCompleted(); List<Contributor> contributors = testSubscriber.getOnNextEvents().get(0); assertThat(contributors.size(), is(1)); -
GithubNetworkͷςετ File file = new File("src/test/assets/json/github_contributors.json"); MockWebServer mockWebServer = new
MockWebServer(); mockWebServer.enqueue(ResponseUtil.createMockResponse(file)); mockWebServer.start(); GithubNetwork githubNetwork = GithubNetwork.getInstance(); githubNetwork = spy(githubNetwork); when(githubNetwork.getBaseUrl()) .thenReturn(mockWebServer.url("/").toString()); TestSubscriber<List<Contributor>> testSubscriber = new TestSubscriber<>(); githubNetwork.getContributors().subscribe(testSubscriber); testSubscriber.assertNoErrors(); testSubscriber.assertCompleted(); List<Contributor> contributors = testSubscriber.getOnNextEvents().get(0); assertThat(contributors.size(), is(1)); -
GithubNetworkͷςετ File file = new File("src/test/assets/json/github_contributors.json"); MockWebServer mockWebServer = new
MockWebServer(); mockWebServer.enqueue(ResponseUtil.createMockResponse(file)); mockWebServer.start(); GithubNetwork githubNetwork = GithubNetwork.getInstance(); githubNetwork = spy(githubNetwork); when(githubNetwork.getBaseUrl()) .thenReturn(mockWebServer.url("/").toString()); TestSubscriber<List<Contributor>> testSubscriber = new TestSubscriber<>(); githubNetwork.getContributors().subscribe(testSubscriber); testSubscriber.assertNoErrors(); testSubscriber.assertCompleted(); List<Contributor> contributors = testSubscriber.getOnNextEvents().get(0); assertThat(contributors.size(), is(1)); -
࣍ • ςετ͕ͳ͍ͱͲ͏ਏ͍ͷ͔ • Couplesͷઃܭ • ςελϏϦςΟͷߴ͍ઃܭ • ςετख๏ɾϑϨʔϜϫʔΫ •
αϯϓϧΞϓϦͰͷςετ • ςετΛॻ͘จԽΛ࡞ΔͨΊʹ • ·ͱΊ -
࣍ • ςετ͕ͳ͍ͱͲ͏ਏ͍ͷ͔ • Couplesͷઃܭ • ςελϏϦςΟͷߴ͍ઃܭ • ςετख๏ɾϑϨʔϜϫʔΫ •
αϯϓϧΞϓϦͰͷςετ • ςετΛॻ͘จԽΛ࡞ΔͨΊʹ • ·ͱΊ -
·ͱΊ • ςετख๏ • Ϣχοτςετ • UIςετ • ςετϑϨʔϜϫʔΫ •
JUnit4 • Espresso • Robolectric -
ResponseUtil public class ResponseUtil { public static MockResponse createMockResponse(
File file) throws IOException { BufferedSource source = Okio.buffer(Okio.source(file)); StringBuilder builder = new StringBuilder(); while (!source.exhausted()) { builder.append(source.readUtf8Line()); } MockResponse mockResponse = new MockResponse(); mockResponse.setBody(builder.toString()); return mockResponse; } } -
GithubRepository public static Observable<List<Contributor>> getContributors() { return Observable.concat( GithubDatabase.getContributors(), GithubNetwork.getInstance().getContributors())
.subscribeOn(Schedulers.newThread()) .observeOn(AndroidSchedulers.mainThread()); }