"Kotlinifying" UI Testing
Nuno Alves de Sousa
Let’s face it, ui testing is probably not on top of every developer's wishlist. Even though it is an important part of the development process, it can be a tedious and monotonous job.
This talk describes CTW’s effort to make writing test cases more efficient, safe, and expressive by leveraging Kotlin-specific features such as function types with receivers, extension and infix functions.
We’ll present a lightweight and type safe Kotlin DSL for ui testing that is being used as an alternative to frameworks such as Cucumber, while still achieving highly readable test cases directly in Kotlin code. We’ll also show how this approach can reduce code duplication, speedup writing test cases and improve productivity by building a repository of reusable actions and assertions that can take advantage of syntax autocompletion provided by the IDE. We’ll even get our feet wet with popular testing frameworks Espresso and UiAutomator and see how we're able to completely abstract away these implementations details.
By the end of this talk:
- you'll be able to write Kotlin test cases in a more natural language. If you don't believe it, test it out;
- you'll know how to extend and customise the DSL with your own keywords;
- you'll see how it is possible to cleanly use different testing frameworks such as Espresso and UiAutomator simultaneously.