Slide 1

Slide 1 text

TESTING building CULTURE

Slide 2

Slide 2 text

https://ordepdev.me/posts/test-driven-developers

Slide 3

Slide 3 text

THIS IS NOT ABOUT TDD!

Slide 4

Slide 4 text

@ordepdev

Slide 5

Slide 5 text

First of all Why testing?

Slide 6

Slide 6 text

“It’s time for software developers to take up the mantle of responsibility for what they produce.

Slide 7

Slide 7 text

Testing is the engineering rigour of software development.

Slide 8

Slide 8 text

Responsibility — the state or fact of being accountable or to blame for something.

Slide 9

Slide 9 text

Rigour — the quality of being extremely thorough and careful.

Slide 10

Slide 10 text

Software Engineering

Slide 11

Slide 11 text

An engineering discipline that is concerned with all aspects of software production.

Slide 12

Slide 12 text

MUCH MORE THAN CODING!

Slide 13

Slide 13 text

Types of Bad Software Projects

Slide 14

Slide 14 text

1. Without tests.

Slide 15

Slide 15 text

Zero Automated Tests.

Slide 16

Slide 16 text

ZERO!

Slide 17

Slide 17 text

Lack of professionalism?

Slide 18

Slide 18 text

Lack of skills?

Slide 19

Slide 19 text

Lack of knowledge?

Slide 20

Slide 20 text

Lack of time to test?

Slide 21

Slide 21 text

It can be all of them.

Slide 22

Slide 22 text

What about software quality?

Slide 23

Slide 23 text

Relax, we test all features with manual testing.

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

2. With Wrongly Designed Tests..

Slide 26

Slide 26 text

Testing is HARD.

Slide 27

Slide 27 text

https://twitter.com/codepipes/status/987934900111138816

Slide 28

Slide 28 text

Testing pitfalls: coupling.

Slide 29

Slide 29 text

Implementation Boundary Testing Boundary

Slide 30

Slide 30 text

Implementation Boundary Testing Boundary ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ❌ ❌

Slide 31

Slide 31 text

Uncertainty and Doubt.

Slide 32

Slide 32 text

Implementation Boundary Testing Boundary ✅ ✅ ✅ ✅ ✅ ❌ ❌ ❌ ❌ ❌

Slide 33

Slide 33 text

Testing pitfalls: performance.

Slide 34

Slide 34 text

Taking too much time? — that’s a no run.

Slide 35

Slide 35 text

Types of Testing

Slide 36

Slide 36 text

1. Testing after the implementation.

Slide 37

Slide 37 text

2. Testing during the implementation.

Slide 38

Slide 38 text

3. Testing that reproduce bugs.

Slide 39

Slide 39 text

It’s our job to build a testing culture!

Slide 40

Slide 40 text

But how?

Slide 41

Slide 41 text

5 rules.

Slide 42

Slide 42 text

1. Every change must have tests.

Slide 43

Slide 43 text

50 100 150 200 Development Unit Tests Functional Tests System Tests Production The cost of bugs

Slide 44

Slide 44 text

Bugs in production are embarrassing and costly.

Slide 45

Slide 45 text

2. Write more than unit tests.

Slide 46

Slide 46 text

https://twitter.com/pwlporto/status/999258562370170880

Slide 47

Slide 47 text

We do not know how much an increase in coverage can decrease the number of defects.” “

Slide 48

Slide 48 text

https://ordepdev.me/posts/code-coverage

Slide 49

Slide 49 text

Mutation testing!

Slide 50

Slide 50 text

def add(x,y) x + y end def add(x,y) x - y end Source Code Mutation

Slide 51

Slide 51 text

Property-based testing! https://hypothesis.works/articles/quickcheck-in-every-language

Slide 52

Slide 52 text

http://blog.jessitron.com/2013/04/property-based-testing-what-is-it.html

Slide 53

Slide 53 text

Contract testing! https://martinfowler.com/bliki/ContractTest.html

Slide 54

Slide 54 text

https://ordepdev.me/posts/boost-your-confidence-with-consumer-driven-contracts

Slide 55

Slide 55 text

Model-based testing! http://mit.bme.hu/~micskeiz/pages/modelbased_testing.html

Slide 56

Slide 56 text

Instead of writing hundreds of test cases, write an abstract model of the system and generate a set of test cases.” “

Slide 57

Slide 57 text

No content

Slide 58

Slide 58 text

Formal methods! https://www.infoq.com/presentations/aws-testing-tla

Slide 59

Slide 59 text

Formal methods use mathematical proof as a complement to system testing in order to ensure correct behavior.” “

Slide 60

Slide 60 text

3. Bug fixing must have tests.

Slide 61

Slide 61 text

Don’t repeat the same bug hunting — write a test!

Slide 62

Slide 62 text

4. Testing code must be reviewed.

Slide 63

Slide 63 text

A well-designed test suite is much easier to read, understand and evolve.

Slide 64

Slide 64 text

Testing code is production code!

Slide 65

Slide 65 text

5. Test suites must be consistent.

Slide 66

Slide 66 text

L12. assertEquals(input, expectation); L35. assertEquals(expectation, input); L43. assertThat(input).isEqualTo( expectation); Assertions

Slide 67

Slide 67 text

L12. assertEquals(input, expectation); L35. assertEquals(expectation, input); L43. assertThat(input).isEqualTo( expectation); Assertions

Slide 68

Slide 68 text

L12. createEntity L35. create_withValidPayload_success L43. create_withValidPayload_shouldPersistEntity Test Methods

Slide 69

Slide 69 text

L12. createEntity L35. create_withValidPayload_success L43. create_withValidPayload_shouldPersistEntity Test Methods

Slide 70

Slide 70 text

We must share the same values, practices, and tools.

Slide 71

Slide 71 text

Enforce them through code reviews, static analysis, and style checking tools.

Slide 72

Slide 72 text

5+1.Test suites must be visible.

Slide 73

Slide 73 text

A failed test is a failed build!

Slide 74

Slide 74 text

Wrapping up.

Slide 75

Slide 75 text

People who are successful at automating tasks tend to work this way in every aspect of their jobs. It is just how they work; it is part of their culture. “ ”

Slide 76

Slide 76 text

Manual work is a bug. acmqueue | january-february 2018

Slide 77

Slide 77 text

ALWAYS BE AUTOMATING!

Slide 78

Slide 78 text

GO AND FIX YOUR BROKEN CULTURE!

Slide 79

Slide 79 text

TESTING building CULTURE @ordepdev ordepdev.me Thanks!