Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Kotlin for Test

Moyuru Aizawa
September 30, 2016

Kotlin for Test

テストにKotlinを導入した

TwitterID変えました。@lvla0805 -> @MoyuruAizawa

Moyuru Aizawa

September 30, 2016
Tweet

More Decks by Moyuru Aizawa

Other Decks in Technology

Transcript

  1. ,PUMJO ‣ +FU#SBJOT ‣ ੩తܕ෇͚ ‣ ΦϒδΣΫτࢦ޲ ‣ GPS+7. "OESPJEBOECSPXTFS

    ‣ #FUUFS+BWB ‣ +BWBͱͷ૬ޓӡ༻ੑ ‣ +BWBͱಉ౳ʹ଎͍ίϯύΠϧϥϯλΠϜ
  2. ‣ +BWBʹൺ΂ͯগͳ͍هड़ྔ ‣ +BWBʹ͸ແ͍๛෋ͳػೳ ‣ ϓϩύςΟ ‣ ҕৡϓϩύςΟ ‣ ֦ுؔ਺

    ‣ σϑΥϧτҾ਺໊લ෇͖Ҿ਺ ‣ ؔ਺Ϧςϥϧ ‣ ߴ֊ؔ਺ ,PUMJOͷ͍͍ͱ͜Ζ
  3. ‣ ϓϩμΫτ͸+BWBͷ·· ‣ ςετίʔυͷஈ֊Ͱ,PUMJOΛ͍֮͑ͯ͘ ‣ "DUJWJUZͷίʔυϨϏϡʔΑΓςετͷίʔυϨϏϡʔͷָ͕ ‣ ࣄલʹߦͬͨ,PUMJOษڧձ ˢͰڭ͍͑ͯ͘ ‣

    ϓϩμΫτʹಋೖ͢Δͱͯ͠ɺͦͷࠒʹ͸ϝϯόʔશһ͕ॻ͚Δঢ়ଶ ʹͳΔ ‣ ͔͠΋ɺςετίʔυͷهड़ྔ΋ݮָͬͯ ςετʹಋೖ
  4. %BP val expectedList = Array(10) { User(it, "name$it") }.toList() orma.prepareInsertIntoUser().executeAll(expectedList)

    val actualList = dao.findAll() actualList.size.should be expectedLis.size actualList.forEachIndexed { i, actual -> actual.should be expectedList[i] } final List<User> expectedList = new ArrayList(); for(int i = 0; i < 10; i++) { expectedList.add( new User(i, "name"+i) ); } orma.prepareInsertIntoUser().executeAll(expectedList); final List<User> actualList = dao.findAll() assertTha(actualList.size(), is(expectedList.size())); for(int i = 0, i < actualList.size(), i++) { assertThat(actualList.get(i), is(expectedList.get(i))); } +BWB ,PUMJO
  5. %BP Array(10) { User().apply { id = it.toLong() name =

    "name$it" age = it height = it weight = it birthDay = date }}.toList() for(int i = 0; i < 10; i++) { User user = new User(); user.setId(i); user.setName("name" + i); user.serAge(i); user.setHeight(i); user.setWeight(i); user.setBirthDay(date); } +BWB ,PUMJO
  6. .PDL val client: FooClient = mock() client.fetch().invoked.thenReturn( Observable.just(expected) ) final

    Client client = mock(FooClient::class); when(client.fetch()).thenReturn(Observable.just(expected)); +BWB ,PUMJO