Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Compiler Based Testing

Compiler Based Testing

Xavier Gouchet

April 03, 2019
Tweet

More Decks by Xavier Gouchet

Other Decks in Programming

Transcript

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

    View Slide

  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

    View Slide

  3. @xgouchet
    Testing is Hard
    Let’s let the compiler do most of the hard
    work for us
    3

    View Slide

  4. @xgouchet
    Kotlin / Swift
    ▧ Statically Typed
    ▧ Strong Typed
    ▧ Type Safe
    ▧ Type Inference
    4

    View Slide

  5. @xgouchet
    Basic use case — JSON
    {
    "id" : 481516,
    "title" : "Lorem ipsum dolor sit amet…",
    "picture" : "https://cloudhost.com/5162342",
    "created": 1553631328
    }
    5

    View Slide

  6. @xgouchet
    Basic use case — App Model
    data class Event(
    val id: Int,
    val title: String,
    val picture: String,
    val created: Int
    }
    6

    View Slide

  7. @xgouchet
    Primitive Aversion
    Primitives are lightweight…
    but lack context
    7

    View Slide

  8. @xgouchet
    Use existing types
    ▧ Integrated in framework and libraries
    ▧ Zero additional work
    data class Event(

    val created: Date
    }
    8

    View Slide

  9. @xgouchet
    Type Alias
    ▧ Give context
    ▧ Prevent invalid assignements
    ▧ Ease Maintenance
    typealias Id = Int
    data class Event(
    val id: Id,

    }
    9

    View Slide

  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

    View Slide

  11. @xgouchet
    Additional gains
    11

    View Slide

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

    View Slide

  13. @xgouchet
    @xgouchet
    Thanks!
    Any questions?
    13
    Presentation template by SlidesCarnival

    View Slide