Slide 1

Slide 1 text

Automated CSS Testing Not Just a Myth @jakobmattsson www.jakobm.com

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

Wikipedia on ”Melodic death metal” ! Melodic death metal is an extreme subgenre of heavy metal music. 
 The Swedish death metal scene did much to popularize the style, which soon centered in the "Gothenburg metal" scene in Gothenburg, Sweden.

Slide 5

Slide 5 text

Wikipedia on ”Melodic death metal” ! Melodic death metal is an extreme subgenre of heavy metal music. 
 The Swedish death metal scene did much to popularize the style, which soon centered in the "Gothenburg metal" scene in Gothenburg, Sweden.

Slide 6

Slide 6 text

Wikipedia on ”Melodic death metal” ! Melodic death metal is an extreme subgenre of heavy metal music. 
 The Swedish death metal scene did much to popularize the style, which soon centered in the "Gothenburg metal" scene in Gothenburg, Sweden.

Slide 7

Slide 7 text

Automated CSS Testing Not Just a Myth

Slide 8

Slide 8 text

The purpose of this presentation: Raise awareness of existing tools Inspire a new workflow

Slide 9

Slide 9 text

Declarative programming

Slide 10

Slide 10 text

Declarative programming is a programming paradigm that expresses the logic of a computation without describing its control flow.” “

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

Mixins Variables Reuse Nesting etc. Operations

Slide 15

Slide 15 text

Write Read

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

New styles are added instead of reuse Unused styles are not removed No overview of how different styles interact Form factors, adaptiveness, responsiveness The true ”write-only” language

Slide 18

Slide 18 text

In computer humor, a write-only language is a programming language with syntax (or semantics) sufficiently dense and bizarre that any routine of significant size is too difficult to understand by other programmers and cannot be safely edited.” “

Slide 19

Slide 19 text

Code quality

Slide 20

Slide 20 text

Functional quality—fitness for purpose ! Structural quality—the degree to which the software was produced correctly

Slide 21

Slide 21 text

Structural quality Reliability Maintainability Size Efficiency Security

Slide 22

Slide 22 text

HOW?

Slide 23

Slide 23 text

By writing automated TESTS!

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

Refactor Red Green 1.Write a test that fails 2.Make the code work 3.Eliminate redundancy

Slide 26

Slide 26 text

Testing CSS

Slide 27

Slide 27 text

Code ??? Visual Declarative Dilemma

Slide 28

Slide 28 text

Let’s try!

Slide 29

Slide 29 text

1 2 3 4 Two for code Two for visuals { { Four approaches

Slide 30

Slide 30 text

1

Slide 31

Slide 31 text

Syntax Checks Checking that the code is actually valid CSS Typically performed by an editor, IDE or plugin

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

2

Slide 34

Slide 34 text

Styleguides & linting Forces best-practices to be followed Syntactically (where to put braces) Semantically (catching common mistakes)

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

Useless without good rules + - Prevents anti-patterns Easy to apply Doesn’t test the end result - - +

Slide 37

Slide 37 text

3

Slide 38

Slide 38 text

Screenshots Compare visuals before and after change Detects impact of change

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

Lots of false positives + - No change can sneak by Implementation agnostic Breaks on content changes - - +

Slide 41

Slide 41 text

4

Slide 42

Slide 42 text

Comparing styles in the DOM Sniff the DOM for all relevant styles Compare them to some expectation

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

Scenario: Standard paragraph color Given I visit "http://localhost:3000" Then "section > p" should have "color" of "rgb(68, 68, 68)"

Slide 45

Slide 45 text

Scenario: Filter the list of audio books Given some audiobooks in the collection When I visit the list of audiobooks And I search for "cor" Then I only see matching titles When I remove the filter Then I see all audiobooks again

Slide 46

Slide 46 text

Style rules != looks + - Resilient to changes Tests live on Writing expectations in code - - +

Slide 47

Slide 47 text

1 2 3 4 Two for code Two for visuals { { Four approaches

Slide 48

Slide 48 text

No content

Slide 49

Slide 49 text

No content

Slide 50

Slide 50 text

No content

Slide 51

Slide 51 text

WHAT is the MISSING PIECE?

Slide 52

Slide 52 text

Design first

Slide 53

Slide 53 text

Refactor Red Green 1.Write a test that fails 2.Make the code work 3.Eliminate redundancy

Slide 54

Slide 54 text

My suggestion: 1. Create the design you want 2. Ensure consistency and compatibility 3. Eliminate redundancy

Slide 55

Slide 55 text

Refactor Red Green 1.Create the design you want 2.Ensure consistency and compatibility 3.Eliminate redundancy

Slide 56

Slide 56 text

5

Slide 57

Slide 57 text

Scenario: Filter the list of audio books Given some audiobooks in the collection When I visit the list of audiobooks And I search for "cor" Then I only see matching titles When I remove the filter Then I see all audiobooks again

Slide 58

Slide 58 text

We are already running user stories No need for manual recording

Slide 59

Slide 59 text

WHAT is the CORRECT LOOK?

Slide 60

Slide 60 text

Red 1.Create the design you want

Slide 61

Slide 61 text

No content

Slide 62

Slide 62 text

Click

Slide 63

Slide 63 text

Red Green 1.Create the design you want 2.Ensure consistency and compatibility

Slide 64

Slide 64 text

No content

Slide 65

Slide 65 text

MARK DIFFS as intended or not intended - THE SYSTEM REMEMBERS

Slide 66

Slide 66 text

Red Green 1.Create the design you want 2.Ensure consistency and compatibility 3.Eliminate redundancy Refactor

Slide 67

Slide 67 text

Design is manual Definition of ”correct” is manual Testing of changes is automatic!

Slide 68

Slide 68 text

Design first

Slide 69

Slide 69 text

No record step + No convoluted ”design spec” + This is make-believe - + Jacking into acceptance tests

Slide 70

Slide 70 text

No content

Slide 71

Slide 71 text

The purpose of this presentation: Raise awareness of existing tools Inspire a new workflow

Slide 72

Slide 72 text

Join in!

Slide 73

Slide 73 text

Automated CSS Testing Not Just a Myth @jakobmattsson www.jakobm.com