Slide 1

Slide 1 text

Are Your Tests Slowing You Down? Trisha Gee

Slide 2

Slide 2 text

https://trishagee.com/books/

Slide 3

Slide 3 text

Gradle is Pioneering DPE Developer Productivity Engineering is a software development practice to maximise developer productivity and happiness.

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

Tests Make You More Productive? Tests Make You More Productive

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

So it’s OK not to write tests, right?

Slide 11

Slide 11 text

“Testing is Xanax for programmers, it’s an anxiety reducing technique.” https://youtu.be/guycIP56YeY Kent Beck

Slide 12

Slide 12 text

Caveats

Slide 13

Slide 13 text

RATED 6+ because apparently 5-year-olds fall asleep during the presentation Some flashing GIF sequences may affect photosensitive viewers This program contains product placement

Slide 14

Slide 14 text

“Nothing is ever really lost to us as long as we remember it.” L.M. Montgomery

Slide 15

Slide 15 text

What slows down your testing?

Slide 16

Slide 16 text

1. Writing Tests Takes Time

Slide 17

Slide 17 text

“Trisha, you’re actually a tester” Liz Keogh (@lunivore)

Slide 18

Slide 18 text

Use Your IDE

Slide 19

Slide 19 text

Buy My Book!

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

AI Will Make You Super Productive

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

Beware, AI lies to you

Slide 25

Slide 25 text

Bring a friend

Slide 26

Slide 26 text

“We recommend that the developers, who are good at writing efficient, maintainable code, work together with the testers, who are good at specifying test cases, to automate tests.” Agile Testing Condensed: A Brief Introduction Lisa Crispin, Janet Gregory

Slide 27

Slide 27 text

https://bit.ly/3RG85vc

Slide 28

Slide 28 text

“Creativity is a wild mind and a disciplined eye.” Dorothy Parker

Slide 29

Slide 29 text

Invest the time in writing to save time troubleshooting

Slide 30

Slide 30 text

2. Troubleshooting Takes Time

Slide 31

Slide 31 text

What is this test anyway?

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

Is it the test that’s wrong, or production code?

Slide 36

Slide 36 text

Let me see…

Slide 37

Slide 37 text

Let me see…

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

Aim for fast feedback and easy reproduction

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

“99.9% of the time the best way to troubleshoot a test is to re-write it so it’s smaller and faster.” Israel Boza Rodriguez (@IsraKaos)

Slide 42

Slide 42 text

Flaky Tests

Slide 43

Slide 43 text

I have made the decision to trust you Body text

Slide 44

Slide 44 text

I have made the decision to trust you Body text

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

Fix your flaky tests!!!

Slide 48

Slide 48 text

https://youtu.be/vHBzZHE4tJ0

Slide 49

Slide 49 text

3. Running Tests Takes Time

Slide 50

Slide 50 text

How do you speed up your tests?

Slide 51

Slide 51 text

Use a build cache

Slide 52

Slide 52 text

Very effective for multi-module projects

Slide 53

Slide 53 text

No cache: Full build required

Slide 54

Slide 54 text

Build cache: Changing a leaf module

Slide 55

Slide 55 text

Build cache: Changing a module’s implementation

Slide 56

Slide 56 text

Build cache: Changing core implementation

Slide 57

Slide 57 text

Remote Build Cache

Slide 58

Slide 58 text

Run tests in parallel (local)

Slide 59

Slide 59 text

Run tests in parallel (CI)

Slide 60

Slide 60 text

No content

Slide 61

Slide 61 text

Test Distribution

Slide 62

Slide 62 text

No content

Slide 63

Slide 63 text

No content

Slide 64

Slide 64 text

Test Distribution Results ‑ ~50% ‑ ~50% ‑ ~50% Doubling the number of executors cuts build time in half

Slide 65

Slide 65 text

Netflix reduced a 62-minute test cycle time down to just under 5 minutes!

Slide 66

Slide 66 text

Let’s use AI!

Slide 67

Slide 67 text

“The test selection procedure selects fewer than a third of the tests that would be selected on the basis of build dependencies” Predictive Test Selection - Meta Research https://research.facebook.com/publications/predictive-test-selection/ Mateusz Machalica, Alex Samylkin, Meredith Porth, Satish Chandra

Slide 68

Slide 68 text

Predictive Test Selection time savings

Slide 69

Slide 69 text

But Trisha, I just have So Many Tests!

Slide 70

Slide 70 text

“Yes, I regularly delete tests that no longer add unique value.” Angie Jones (@techgirl1908)

Slide 71

Slide 71 text

No content

Slide 72

Slide 72 text

No content

Slide 73

Slide 73 text

No content

Slide 74

Slide 74 text

Like any performance problem, focus on the worst-performers first

Slide 75

Slide 75 text

No content

Slide 76

Slide 76 text

“Once things like databases become a hindrance, optimise the testing loop, mock things out to run things fast. You can run locally and you don't have all the same infra dependencies as someone else.” On DevEx, PaaS, and Testing in Production https://bit.ly/3ZA0uQM Kelsey Hightower

Slide 77

Slide 77 text

Look out for expensive setup and tear down

Slide 78

Slide 78 text

No content

Slide 79

Slide 79 text

No content

Slide 80

Slide 80 text

Respect your test code

Slide 81

Slide 81 text

No content

Slide 82

Slide 82 text

No content

Slide 83

Slide 83 text

No content

Slide 84

Slide 84 text

⬢ Separation of concerns ⬢ Encapsulation ⬢ SOLID ⬢ DRY ⬢ Descriptive naming ⬢ Modularisation ⬢ Designing for performance

Slide 85

Slide 85 text

Tension between these ideals

Slide 86

Slide 86 text

“Tidying is software design addressing you, your relationship to your code, and ultimately your relationship with yourself…. Tidying is geek self-care.” Tidy First? Kent Beck

Slide 87

Slide 87 text

Summary

Slide 88

Slide 88 text

Automate as much as possible

Slide 89

Slide 89 text

There are solutions out there designed for exactly this problem

Slide 90

Slide 90 text

There is a time investment in writing tests, because there should be thinking involved

Slide 91

Slide 91 text

“Your best and wisest refuge from all troubles is in your science.” Ada Lovelace

Slide 92

Slide 92 text

Thank you!