Enviar pesquisa
Carregar
Kotlinでテストコードを書く
•
8 gostaram
•
8,930 visualizações
Shoichi Matsuda
Seguir
第3回kotlin勉強会 @ SanSan
Leia menos
Leia mais
Tecnologia
Denunciar
Compartilhar
Denunciar
Compartilhar
1 de 31
Baixar agora
Baixar para ler offline
Recomendados
Unit Testing in Kotlin
Unit Testing in Kotlin
Egor Andreevich
Dependency Injection with CDI in 15 minutes
Dependency Injection with CDI in 15 minutes
Antonio Goncalves
JEEConf 2017 - Having fun with Javassist
JEEConf 2017 - Having fun with Javassist
Anton Arhipov
JEEConf 2017 - The hitchhiker’s guide to Java class reloading
JEEConf 2017 - The hitchhiker’s guide to Java class reloading
Anton Arhipov
Java objects on steroids
Java objects on steroids
Romain Rochegude
NodeJS Spring style Inversifyjs
NodeJS Spring style Inversifyjs
Mathieu Breton
Java Bytecode for Discriminating Developers - JavaZone 2011
Java Bytecode for Discriminating Developers - JavaZone 2011
Anton Arhipov
Spock Testing Framework - The Next Generation
Spock Testing Framework - The Next Generation
BTI360
Recomendados
Unit Testing in Kotlin
Unit Testing in Kotlin
Egor Andreevich
Dependency Injection with CDI in 15 minutes
Dependency Injection with CDI in 15 minutes
Antonio Goncalves
JEEConf 2017 - Having fun with Javassist
JEEConf 2017 - Having fun with Javassist
Anton Arhipov
JEEConf 2017 - The hitchhiker’s guide to Java class reloading
JEEConf 2017 - The hitchhiker’s guide to Java class reloading
Anton Arhipov
Java objects on steroids
Java objects on steroids
Romain Rochegude
NodeJS Spring style Inversifyjs
NodeJS Spring style Inversifyjs
Mathieu Breton
Java Bytecode for Discriminating Developers - JavaZone 2011
Java Bytecode for Discriminating Developers - JavaZone 2011
Anton Arhipov
Spock Testing Framework - The Next Generation
Spock Testing Framework - The Next Generation
BTI360
Spock Framework
Spock Framework
Леонид Ставила
Introduction to CDI and DI in Java EE 6
Introduction to CDI and DI in Java EE 6
Ray Ploski
CDI: How do I ?
CDI: How do I ?
Antonio Goncalves
Migrating to JUnit 5
Migrating to JUnit 5
Rafael Winterhalter
Spock: Test Well and Prosper
Spock: Test Well and Prosper
Ken Kousen
Agile Android
Agile Android
Godfrey Nolan
15 tips to improve your unit tests (Droidcon Berlin 2016 Barcamp)
15 tips to improve your unit tests (Droidcon Berlin 2016 Barcamp)
Danny Preussler
Demystifying dependency Injection: Dagger and Toothpick
Demystifying dependency Injection: Dagger and Toothpick
Danny Preussler
Voxxed Days Vilnius 2015 - Having fun with Javassist
Voxxed Days Vilnius 2015 - Having fun with Javassist
Anton Arhipov
Spock Framework
Spock Framework
Daniel Kolman
Agile Swift
Agile Swift
Godfrey Nolan
Spock
Spock
Evgeny Borisov
Smarter Testing With Spock
Smarter Testing With Spock
IT Weekend
Martin Anderson - threads v actors
Martin Anderson - threads v actors
bloodredsun
Using Reflections and Automatic Code Generation
Using Reflections and Automatic Code Generation
Ivan Dolgushin
Tomasz Polanski - Automated mobile testing 2016 - Testing: why, when, how
Tomasz Polanski - Automated mobile testing 2016 - Testing: why, when, how
Tomasz Polanski
The Groovy Way of Testing with Spock
The Groovy Way of Testing with Spock
Naresha K
Android Design Patterns
Android Design Patterns
Godfrey Nolan
9.Spring DI_4
9.Spring DI_4
탑크리에듀(구로디지털단지역3번출구 2분거리)
Unit/Integration Testing using Spock
Unit/Integration Testing using Spock
Anuj Aneja
Android & Kotlin - The code awakens #01
Android & Kotlin - The code awakens #01
Omar Miatello
Coroutines for Kotlin Multiplatform in Practise
Coroutines for Kotlin Multiplatform in Practise
Christian Melchior
Mais conteúdo relacionado
Mais procurados
Spock Framework
Spock Framework
Леонид Ставила
Introduction to CDI and DI in Java EE 6
Introduction to CDI and DI in Java EE 6
Ray Ploski
CDI: How do I ?
CDI: How do I ?
Antonio Goncalves
Migrating to JUnit 5
Migrating to JUnit 5
Rafael Winterhalter
Spock: Test Well and Prosper
Spock: Test Well and Prosper
Ken Kousen
Agile Android
Agile Android
Godfrey Nolan
15 tips to improve your unit tests (Droidcon Berlin 2016 Barcamp)
15 tips to improve your unit tests (Droidcon Berlin 2016 Barcamp)
Danny Preussler
Demystifying dependency Injection: Dagger and Toothpick
Demystifying dependency Injection: Dagger and Toothpick
Danny Preussler
Voxxed Days Vilnius 2015 - Having fun with Javassist
Voxxed Days Vilnius 2015 - Having fun with Javassist
Anton Arhipov
Spock Framework
Spock Framework
Daniel Kolman
Agile Swift
Agile Swift
Godfrey Nolan
Spock
Spock
Evgeny Borisov
Smarter Testing With Spock
Smarter Testing With Spock
IT Weekend
Martin Anderson - threads v actors
Martin Anderson - threads v actors
bloodredsun
Using Reflections and Automatic Code Generation
Using Reflections and Automatic Code Generation
Ivan Dolgushin
Tomasz Polanski - Automated mobile testing 2016 - Testing: why, when, how
Tomasz Polanski - Automated mobile testing 2016 - Testing: why, when, how
Tomasz Polanski
The Groovy Way of Testing with Spock
The Groovy Way of Testing with Spock
Naresha K
Android Design Patterns
Android Design Patterns
Godfrey Nolan
9.Spring DI_4
9.Spring DI_4
탑크리에듀(구로디지털단지역3번출구 2분거리)
Unit/Integration Testing using Spock
Unit/Integration Testing using Spock
Anuj Aneja
Mais procurados
(20)
Spock Framework
Spock Framework
Introduction to CDI and DI in Java EE 6
Introduction to CDI and DI in Java EE 6
CDI: How do I ?
CDI: How do I ?
Migrating to JUnit 5
Migrating to JUnit 5
Spock: Test Well and Prosper
Spock: Test Well and Prosper
Agile Android
Agile Android
15 tips to improve your unit tests (Droidcon Berlin 2016 Barcamp)
15 tips to improve your unit tests (Droidcon Berlin 2016 Barcamp)
Demystifying dependency Injection: Dagger and Toothpick
Demystifying dependency Injection: Dagger and Toothpick
Voxxed Days Vilnius 2015 - Having fun with Javassist
Voxxed Days Vilnius 2015 - Having fun with Javassist
Spock Framework
Spock Framework
Agile Swift
Agile Swift
Spock
Spock
Smarter Testing With Spock
Smarter Testing With Spock
Martin Anderson - threads v actors
Martin Anderson - threads v actors
Using Reflections and Automatic Code Generation
Using Reflections and Automatic Code Generation
Tomasz Polanski - Automated mobile testing 2016 - Testing: why, when, how
Tomasz Polanski - Automated mobile testing 2016 - Testing: why, when, how
The Groovy Way of Testing with Spock
The Groovy Way of Testing with Spock
Android Design Patterns
Android Design Patterns
9.Spring DI_4
9.Spring DI_4
Unit/Integration Testing using Spock
Unit/Integration Testing using Spock
Semelhante a Kotlinでテストコードを書く
Android & Kotlin - The code awakens #01
Android & Kotlin - The code awakens #01
Omar Miatello
Coroutines for Kotlin Multiplatform in Practise
Coroutines for Kotlin Multiplatform in Practise
Christian Melchior
Develop your next app with kotlin @ AndroidMakersFr 2017
Develop your next app with kotlin @ AndroidMakersFr 2017
Arnaud Giuliani
比XML更好用的Java Annotation
比XML更好用的Java Annotation
javatwo2011
Kotlin Generation
Kotlin Generation
Minseo Chayabanjonglerd
Mobile Day - React Native
Mobile Day - React Native
Software Guru
Dependency Injection for Android
Dependency Injection for Android
First Tuesday Bergen
Dependency Injection for Android @ Ciklum speakers corner Kiev 29. May 2014
Dependency Injection for Android @ Ciklum speakers corner Kiev 29. May 2014
First Tuesday Bergen
Why Spring <3 Kotlin
Why Spring <3 Kotlin
VMware Tanzu
Android and the Seven Dwarfs from Devox'15
Android and the Seven Dwarfs from Devox'15
Murat Yener
BOF2644 Developing Java EE 7 Scala apps
BOF2644 Developing Java EE 7 Scala apps
Peter Pilgrim
JUnit 5
JUnit 5
Scott Leberknight
Spring Boot
Spring Boot
Jiayun Zhou
Workshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testing
Visual Engineering
OOP2017: Containerized End-2-End Testing – automate it!
OOP2017: Containerized End-2-End Testing – automate it!
Tobias Schneck
Junit 5 - Maior e melhor
Junit 5 - Maior e melhor
Tiago de Freitas Lima
Alexey Buzdin "Maslow's Pyramid of Android Testing"
Alexey Buzdin "Maslow's Pyramid of Android Testing"
IT Event
Android Unit Test
Android Unit Test
Phuoc Bui
Nice to meet Kotlin
Nice to meet Kotlin
Jieyi Wu
Csmr2012 bettenburg presentation
Csmr2012 bettenburg presentation
SAIL_QU
Semelhante a Kotlinでテストコードを書く
(20)
Android & Kotlin - The code awakens #01
Android & Kotlin - The code awakens #01
Coroutines for Kotlin Multiplatform in Practise
Coroutines for Kotlin Multiplatform in Practise
Develop your next app with kotlin @ AndroidMakersFr 2017
Develop your next app with kotlin @ AndroidMakersFr 2017
比XML更好用的Java Annotation
比XML更好用的Java Annotation
Kotlin Generation
Kotlin Generation
Mobile Day - React Native
Mobile Day - React Native
Dependency Injection for Android
Dependency Injection for Android
Dependency Injection for Android @ Ciklum speakers corner Kiev 29. May 2014
Dependency Injection for Android @ Ciklum speakers corner Kiev 29. May 2014
Why Spring <3 Kotlin
Why Spring <3 Kotlin
Android and the Seven Dwarfs from Devox'15
Android and the Seven Dwarfs from Devox'15
BOF2644 Developing Java EE 7 Scala apps
BOF2644 Developing Java EE 7 Scala apps
JUnit 5
JUnit 5
Spring Boot
Spring Boot
Workshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testing
OOP2017: Containerized End-2-End Testing – automate it!
OOP2017: Containerized End-2-End Testing – automate it!
Junit 5 - Maior e melhor
Junit 5 - Maior e melhor
Alexey Buzdin "Maslow's Pyramid of Android Testing"
Alexey Buzdin "Maslow's Pyramid of Android Testing"
Android Unit Test
Android Unit Test
Nice to meet Kotlin
Nice to meet Kotlin
Csmr2012 bettenburg presentation
Csmr2012 bettenburg presentation
Mais de Shoichi Matsuda
Yahoo! JAPANとKotlin
Yahoo! JAPANとKotlin
Shoichi Matsuda
広がりを見せるAndroidプラットフォーム
広がりを見せるAndroidプラットフォーム
Shoichi Matsuda
2015冬から始めるKotlin
2015冬から始めるKotlin
Shoichi Matsuda
Gradleスクリプトを読み解く
Gradleスクリプトを読み解く
Shoichi Matsuda
プログラミング言語は怖くない
プログラミング言語は怖くない
Shoichi Matsuda
TddでFizzBuzzしてみる in Swift
TddでFizzBuzzしてみる in Swift
Shoichi Matsuda
モックライブラリを使ってきちんとユニットテストする #Objective-C
モックライブラリを使ってきちんとユニットテストする #Objective-C
Shoichi Matsuda
テストを書きたいあなたが意識すべきただ一つのこと
テストを書きたいあなたが意識すべきただ一つのこと
Shoichi Matsuda
アプリでもオブジェクト指向エクササイズ(Potatotips#3)
アプリでもオブジェクト指向エクササイズ(Potatotips#3)
Shoichi Matsuda
Mais de Shoichi Matsuda
(9)
Yahoo! JAPANとKotlin
Yahoo! JAPANとKotlin
広がりを見せるAndroidプラットフォーム
広がりを見せるAndroidプラットフォーム
2015冬から始めるKotlin
2015冬から始めるKotlin
Gradleスクリプトを読み解く
Gradleスクリプトを読み解く
プログラミング言語は怖くない
プログラミング言語は怖くない
TddでFizzBuzzしてみる in Swift
TddでFizzBuzzしてみる in Swift
モックライブラリを使ってきちんとユニットテストする #Objective-C
モックライブラリを使ってきちんとユニットテストする #Objective-C
テストを書きたいあなたが意識すべきただ一つのこと
テストを書きたいあなたが意識すべきただ一つのこと
アプリでもオブジェクト指向エクササイズ(Potatotips#3)
アプリでもオブジェクト指向エクササイズ(Potatotips#3)
Último
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
Antenna Manufacturer Coco
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
Martijn de Jong
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
The Digital Insurer
Slack Application Development 101 Slides
Slack Application Development 101 Slides
praypatel2
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
sudhanshuwaghmare1
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
Delhi Call girls
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
The Digital Insurer
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Drew Madelung
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
naman860154
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
apidays
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
debabhi2
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
hans926745
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
Enterprise Knowledge
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Katpro Technologies
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
Rafal Los
🐬 The future of MySQL is Postgres 🐘
🐬 The future of MySQL is Postgres 🐘
RTylerCroy
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
HampshireHUG
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
wesley chun
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
Delhi Call girls
Último
(20)
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Slack Application Development 101 Slides
Slack Application Development 101 Slides
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
🐬 The future of MySQL is Postgres 🐘
🐬 The future of MySQL is Postgres 🐘
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
Kotlinでテストコードを書く
1.
2.
3.
4.
5.
6.
7.
8.
android { sourceSets { main.java.srcDirs
+= 'src/main/kotlin' test.java.srcDirs += 'src/test/kotlin' androidTest.java.srcDirs += 'src/androidTest/kotlin' } }
9.
//ExampleUnitTest.java public class ExampleUnitTest
{ @Test public void addition_isCorrect() { assertEquals(4, 2 + 2); } }
10.
//ExampleUnitTest.kt class ExampleUnitTest { @Test fun
addition_isCorrect() { assertEquals(4, 2 + 2) } }
11.
12.
13.
14.
15.
//app/build.gradle dependencies { testCompile 'org.mockito:mockito-core:1.10.19' }
16.
//KotlinSimpleMockitoTest.kt class KotlinSimpleMockitoTest { @Test fun
Context () { val context = Mockito.mock(Context::class.java) Mockito.`when`(context.packageName).thenReturn("shoma2da") val packageName = context.getPackageName(); Assert.assertEquals("shoma2da", packageName); } }
17.
//User.kt class User(val birthYear:Int)
{ fun getAge() = 2016 - birthYear }
18.
//UserTest.kt class UserTest { @Test fun
User () { val user = Mockito.mock(User::class.java) Mockito.`when`(user.getAge()).thenReturn(1) val age = user.getAge() Assert.assertEquals(1, age) } }
19.
//logcat org.mockito.exceptions.base.MockitoException: Cannot mock/spy class
YOUR_PACKAGE.User Mockito cannot mock/spy following: - final classes - anonymous classes - primitive types
20.
open
21.
22.
//User.kt open class User(val
birthYear:Int) { open fun getAge() = 2016 - birthYear }
23.
24.
//User.kt interface User { fun
getAge():Int } class UserImpl(val birthYear:Int) : User { override fun getAge() = 2016 - birthYear }
25.
26.
//UserTest.kt @RunWith(PowerMockRunner::class) @PrepareForTest(User::class) class UserTest { @Test fun
User () { val user = PowerMockito.mock(User::class.java) Mockito.`when`(user.getAge()).thenReturn(1) val age = user.getAge() Assert.assertEquals(1, age) } } //build.gradle dependencies { testCompile 'org.powermock:powermock-module-junit4:1.6.2' testCompile 'org.powermock:powermock-api-mockito:1.6.2' }
27.
28.
29.
Baixar agora