Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Simplifying Application Development with Kotlin Multiplatform Mobile

You're reading from   Simplifying Application Development with Kotlin Multiplatform Mobile Write robust native applications for iOS and Android efficiently

Arrow left icon
Product type Paperback
Published in Mar 2022
Publisher Packt
ISBN-13 9781801812580
Length 184 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Robert Nagy Robert Nagy
Author Profile Icon Robert Nagy
Robert Nagy
Arrow right icon
View More author details
Toc

Table of Contents (15) Chapters Close

Preface 1. Section 1 - Getting Started with Multiplatform Mobile Development Using Kotlin
2. Chapter 1: The Battle Between Native, Cross-Platform, and Multiplatform FREE CHAPTER 3. Chapter 2: Exploring the Three Compilers of Kotlin Multiplatform 4. Chapter 3: Introducing Kotlin for Swift Developers 5. Section 2 - Code Sharing between Android and iOS
6. Chapter 4: Introducing the KMM Learning Project 7. Chapter 5: Writing Shared Code 8. Chapter 6: Writing the Android Consumer App 9. Chapter 7: Writing an iOS Consumer App 10. Section 3 - Supercharging Yourself for the Next Steps
11. Chapter 8: Exploring Tips and Best Practices 12. Chapter 9: Integrating KMM into Existing Android and iOS Apps 13. Chapter 10: Summary and Your Next Steps 14. Other Books You May Enjoy

Testing shared code

Testing shared code in KMP is similar to writing code in KMP: in your shared code, you will have to write platform-agnostic code. This means no third-party testing frameworks or libraries that target a specific platform, JVM, JS, or iOS, such as XCTest or JUnit. Thankfully, KMP already provides a library that targets JVM, JS, and Native: https://kotlinlang.org/api/latest/kotlin.test/.

kotlin.test provides an Asserter abstraction with a DefaultAsserter that is dependency-free, but it also provides JUnitAsserter, JUnit5Asserter, and TestNGAsserter so that you can choose the one you'd like to use in your JVM or Android targets.

You can also implement your own Asserter implementations for the different platforms if you wish. The same expect/actual mechanism can be used in your tests as well.

But what about which test double (https://en.wikipedia.org/wiki/Test_double) you should choose to test your shared code – Stubs, Mocks, Spies, Fakes, or Dummies...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image