Slide 1

Slide 1 text

How Scala made my tests more meaningful by Piotr Gabryanczyk

Slide 2

Slide 2 text

What is a good test? • easy to write • easy to read and understand • easy to evolve with the system • bang for buck • meaningful

Slide 3

Slide 3 text

Which tests are meaningful? • written using abstractions appropriate for the component you are testing • using vocabulary defined by the API of the component

Slide 4

Slide 4 text

Meaningful test

Slide 5

Slide 5 text

Are integration tests more meaningful?

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

Why is it hard to write integration tests?

Slide 8

Slide 8 text

Why is it hard to write integration tests?

Slide 9

Slide 9 text

Why is it hard to write integration tests?

Slide 10

Slide 10 text

Why is it hard to write integration tests?

Slide 11

Slide 11 text

Hexagonal Architecture

Slide 12

Slide 12 text

Adapters raise the level of abstraction

Slide 13

Slide 13 text

Adapters raise the level of abstraction

Slide 14

Slide 14 text

Fake for every adapter

Slide 15

Slide 15 text

Mixing fake and real adapters

Slide 16

Slide 16 text

Writing fakes is easy - higher order functions

Slide 17

Slide 17 text

Very bad test data

Slide 18

Slide 18 text

Very bad test data

Slide 19

Slide 19 text

Builder Pattern

Slide 20

Slide 20 text

Builder Pattern

Slide 21

Slide 21 text

Builder Pattern

Slide 22

Slide 22 text

It is easy if you build it up gradually

Slide 23

Slide 23 text

It is easy if you build it up gradually

Slide 24

Slide 24 text

Everything depends on everything

Slide 25

Slide 25 text

Peers vs Internals Wikipedia DB Graph Analyzer XML Parser

Slide 26

Slide 26 text

Fewer dependencies Wikipedia DB Graph Analyzer XML Parser DB Adapter Wikipedia Adapter

Slide 27

Slide 27 text

Creating sub- systems is easy!

Slide 28

Slide 28 text

Creating sub- systems is easy!

Slide 29

Slide 29 text

System is a one class with 5 dependencies

Slide 30

Slide 30 text

Creating of the system is easy!

Slide 31

Slide 31 text

Writing integration tests in Scala is Easy!

Slide 32

Slide 32 text

ScalaTest - FreeSpec

Slide 33

Slide 33 text

DSL example

Slide 34

Slide 34 text

Infix notation

Slide 35

Slide 35 text

Implicits

Slide 36

Slide 36 text

Test Labels

Slide 37

Slide 37 text

Test Labels

Slide 38

Slide 38 text

Test Labels

Slide 39

Slide 39 text

Matchers

Slide 40

Slide 40 text

Specs2

Slide 41

Slide 41 text

Expecty

Slide 42

Slide 42 text

ScalaCheck

Slide 43

Slide 43 text

Piotr Gabryanczyk @piotrga [email protected]