4. about:me
• Finished university in 2001
• Switched to Java in 2003
• Switched to Kotlin in 2016
• Worked for eBay, Groupon, Viacom
• Android Engineer at SoundCloud
• GDE since 2016
5. about:sc
• Founded 2007 in Berlin, Germany
• World’s largest open audio platform
• 200 million tracks, 25 million creators (2019)
• Around 500 employees
• Playstore: 100,000,000+ installs
• Ratings: 4.7 (5,500,500)
Our Mission
is to lead
what’s next in
music.
Our Purpose
is to accelerate
creators' careers.
16. The 3 rules of TDD
•Create a unit tests that fails
•Write just enough production code
to makes that test pass.
•Clean up the mess you just made.
micro-cycle (minutes)
17. The 3 rules of TDD
•Create a unit tests that fails
•Write just enough production code
to makes that test pass.
•Clean up the mess you just made.
micro-cycle (minutes)
18. The 3 rules of TDD
•Create a unit tests that fails
•Write just enough production code
to makes that test pass.
•Clean up the mess you just made.
micro-cycle (minutes)
19. The 3 rules of TDD
•Create a unit tests that fails
•Write just enough production code
to makes that test pass.
•Clean up the mess you just made.
micro-cycle (minutes)
20. The 3 rules of TDD
•Create a unit tests that fails
•Write just enough production code
to makes that test pass.
•Clean up the mess you just made.
•REPEAT
micro-cycle (minutes)
22. Be precise:
•You must not write more of a test than
is sufficient to fail
•Not compiling is failing!
•You must not write more production
code than is sufficient to make the
currently failing test pass
micro-cycle (minutes)
23. Be precise:
•You must not write more of a test than
is sufficient to fail
•Not compiling is failing!
•You must not write more production
code than is sufficient to make the
currently failing test pass.
micro-cycle (minutes)
24. Be precise:
•You must not write more of a test than
is sufficient to fail
•Not compiling is failing!
•You must not write more production
code than is sufficient to make the
currently failing test pass.
micro-cycle (minutes)
64. TDD and tests
•Kent Beck spoke about behavior of the system in his TDD
book
•A “unit” does not mean every class/method!
Unit came from Blackbox!
•TDD tests behaviors not implementation details!
•What your software does, is stable!
How it does this, is unstable!
TDD what went wrong: https://www.youtube.com/watch?v=EZ05e7EMOLM
65. TDD and tests
•Kent Beck spoke about behavior of the system in his TDD
book
•A “unit” does not mean every class/method!
Unit came from Blackbox!
•TDD tests behaviors not implementation details!
•What your software does, is stable!
How it does this, is unstable!
TDD what went wrong: https://www.youtube.com/watch?v=EZ05e7EMOLM
66. TDD and tests
•Kent Beck spoke about behavior of the system in his TDD
book
•A “unit” does not mean every class/method!
Unit came from Blackbox!
•TDD tests behaviors not implementation details!
•What your software does, is stable!
How it does this, is unstable!
TDD what went wrong: https://www.youtube.com/watch?v=EZ05e7EMOLM
67. TDD and tests
•Kent Beck spoke about behavior of the system in his TDD
book
•A “unit” does not mean every class/method!
Unit came from Blackbox!
•TDD tests behaviors not implementation details!
•What your software does, is stable!
How it does this, is unstable!
TDD what went wrong: https://www.youtube.com/watch?v=EZ05e7EMOLM
68. TDD and tests
• unit test must be fast!
• no databases
• no network calls
• if -> integration test
martinfowler.com
72. Android SDK under test
•Wrap things
class BundleBuilder
@Inject
constructor() {
operator fun invoke() = Bundle()
}
73. Android SDK under test
•Wrap things
class BundleBuilder
@Inject
constructor() {
operator fun invoke() = Bundle()
operator fun invoke(vararg pairs: Pair<String, Any?>) =
bundleOf(*pairs)
}
74. Android SDK under test
•Wrap things (keep it simple)
@VisibleForTesting
var bundleBuilder: () -> Bundle = { Bundle() }
80. Robolectric 4
•Android builds are already slow!
•Robolectric is just another “android device”
•Not compatible with Junit5
•Still slower than pure junit
•It’s goal: replace Espresso not JVM Tests
81. be pragmatic, not dogmatic
@RobolectricNeededAsOf(Uri::class)
@RunWith(RobolectricTestRunner::class)
class UploadStarterTest {
98. Isn’t it slow?
•Single + Initial feature will take longer
•Bugfixing phase is shorter
•Debugging disappears
•Ci finds bugs before QA does
• Long term it’s much faster no more big rewrite
99. Isn’t it slow?
•Single + Initial feature will take longer
•Bugfixing phase is shorter
•Debugging disappears
•Ci finds bugs before QA does
• Long term it’s much faster no more big rewrite
100. Isn’t it slow?
•Single + Initial feature will take longer
•Bugfixing phase is shorter
•Debugging disappears
•Ci finds bugs before QA does
• Long term it’s much faster no more big rewrite
101. Isn’t it slow?
•Single + Initial feature will take longer
•Bugfixing phase is shorter
•Debugging disappears
•Ci finds bugs before QA does
• Long term it’s much faster no more big rewrite
102. Isn’t it slow?
•Single + Initial feature will take longer
•Bugfixing phase is shorter
•Debugging disappears
•Ci finds bugs before QA does
• Long term it’s much faster no more big rewrite
113. “Never ask permission to refactor.
Never ask permission to write tests.
You do these things because you KNOW
they are the best way to go fast.“
Robert C Martin
121. More resources
• TDD what went wrong:
https://www.youtube.com/watch?v=EZ05e7EMOLM
• The three laws of TDD by Uncle Bob
https://www.youtube.com/watch?v=AoIfc5NwRks
• TDD for those who don't need it
https://www.youtube.com/watch?v=a6oP24CSdUg