Compiler Based Testing

Compiler Based Testing

Cf95f93e78f6d6dd0630049396f723c6?s=128

Xavier Gouchet

April 03, 2019
Tweet

Transcript

  1. @xgouchet Compiler based Testing CodeMobile UK 2019 - Chester

  2. @xgouchet About me… Xavier F. Gouchet Android developer since the

    Cupcake years Lead Android Engineer at WorkWell @xgouchet on every social network you can think of… 2
  3. @xgouchet Testing is Hard Let’s let the compiler do most

    of the hard work for us 3
  4. @xgouchet Kotlin / Swift ▧ Statically Typed ▧ Strong Typed

    ▧ Type Safe ▧ Type Inference 4
  5. @xgouchet Basic use case — JSON { "id" : 481516,

    "title" : "Lorem ipsum dolor sit amet…", "picture" : "https://cloudhost.com/5162342", "created": 1553631328 } 5
  6. @xgouchet Basic use case — App Model data class Event(

    val id: Int, val title: String, val picture: String, val created: Int } 6
  7. @xgouchet Primitive Aversion Primitives are lightweight… but lack context 7

  8. @xgouchet Use existing types ▧ Integrated in framework and libraries

    ▧ Zero additional work data class Event( … val created: Date } 8
  9. @xgouchet Type Alias ▧ Give context ▧ Prevent invalid assignements

    ▧ Ease Maintenance typealias Id = Int data class Event( val id: Id, … } 9
  10. @xgouchet Type Checking ▧ Limit Primitive Scope ▧ Validate data

    data class Url(val value: String) { init { val parsedUrl = URL(value) } } data class Event( … val picture: Url } 10
  11. @xgouchet Additional gains 11

  12. @xgouchet Bonus ▧ Share common operations ▧ Force explicit types

    ▧ Simplify complex structure 12
  13. @xgouchet @xgouchet Thanks! Any questions? 13 Presentation template by SlidesCarnival