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

kotlin season 1 - Part 20 Presenter Test

TaeHwan
November 24, 2016

kotlin season 1 - Part 20 Presenter Test

2016년 유데미 Kotlin 강의를 공개합니다.

동영상 : https://www.youtube.com/watch?v=-YM-PKDE114

2회 분은 유데미에서 확인 가능합니다.
http://bit.ly/2UpaJUR

TaeHwan

November 24, 2016
Tweet

More Decks by TaeHwan

Other Decks in Education

Transcript

  1. ࢠ೒ ௏٘ח!!! 4 Sample Code GitHub ࠳۠஖ : 13-Presenter-Test 4

    https://github.com/taehwandev/Kotlin-Udemy- Sample/tree/13-Presetner-Test ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016 2
  2. য়ט਷ 4 Mockito ࣗѐ 4 Presenter పझ౟ ௏٘ ੘ࢿ ରࣁ؀

    উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016 3
  3. Mockito 4 Tasty mocking framework for unit tests in Java

    ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016 4
  4. Mockitoਸ ࢎਊೞӝ ਤ೧ࢲ repositories { jcenter() } dependencies { testCompile

    "org.mockito:mockito-core:2.2.21" } ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016 5
  5. Mockito - verify import static org.mockito.Mockito.*; // 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(); ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016 6
  6. Mockito - verify // 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 prints "first" System.out.println(mockedList.get(0)); // the following prints "null" because get(999) was not stubbed System.out.println(mockedList.get(999)); ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016 7
  7. Mockito-Kotlin 4 Kotlin ޙߨী ݏѱ పझ౟ೡ ࣻ ੓ח mockito 4

    Mockito-Kotlin ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016 9
  8. Mockito-Kotlin repositories { mavenCentral() } dependencies { testCompile 'com.nhaarman:mockito-kotlin:0.12.1' }

    ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016 10
  9. Mockito-Kotlin ୶о೮؊פ য়ܨо! Conflict with dependency 'org.jetbrains.kotlin:kotlin- stdlib'. Resolved versions

    for app (1.0.5) and test app (1.0.5-2) differ. See http://g.co/androidstudio/app- test-app-conflict for details. ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016 11
  10. Mockito-Kotlin repositories { mavenCentral() } dependencies { testCompile 'com.nhaarman:mockito-kotlin:0.12.1', {

    exclude group: "org.jetbrains.kotlin", module: 'kotlin-stdlib' } } ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016 12
  11. Mockito-Kotlin @Test fun test(){ /* Given */ val mock =

    mock<MyClass> { on { getText() } doReturn "text" } val classUnderTest = ClassUnderTest(mock) /* When */ classUnderTest.doAction() /* Then */ verify(mock).doSomething(any()) } ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016 14
  12. ଵҊ ੗ܐ 4 Mockito 4 Mockito-Kotlin 4 androidTest - JUnit4,

    Espressoܳ ੉ਊೠ పझ౟ ௏٘ ੘ࢿ ରࣁ؀ উ٘۽੉٘ ѐߊ ঱য ௏ౣܽ, द੘ೞӝ thdev.tech, 2016 15