Minitest 6: Test Feistier! Ryan Davis, Seattle.rb Minitest 6 · Presentation Sammich 7. Minitest 6:...

Preview:

Citation preview

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Minitest 6: Test Feistier!

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Setting ExpectationsOverview / Idea TalkLittle CodeTesters at All Levels

265 slides / 40 min = ~7 spm�2

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

🎺🎷

🎊🎉�3

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

1000+ Gems!

�4

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Narrative?

�5

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider�6

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

%?

�6

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

%?🥙?

�6

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

%?🥙?🍔?

�6

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

what you’ll tell themActual Content

what you told them

Presentation Sammich

�7

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

😞

�8

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

➡🍔💬 = 👎

�9

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider�10

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

🗣🍔💬 = 🤢

�11

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider�12

https://www.flickr.com/photos/hsincheng_lin/12180213616

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

🥅

�13

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Sorry! 😨

�14

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

💍

�15

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

🤷2

�16

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

🖐Audience🖐

�17

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Beginner?

�18

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Minitest User?

�19

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

RSpec User?

�20

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

RSpec Fanatic?

�21

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

All are Welcome!

�22

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

(I Heckle Back)

�23

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

My Baby: Minitest

�24

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

�25

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Testing=Passion

�26

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

1995!

�27

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Pre-XP

�28

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

TDDesign

�29

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

TDDevelopment

�30

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

TDD+YAGNI

�31

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Better Software

�32

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Every Time�33

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Every Time�33

(Almost)

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Minitest

�34

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

What I am talking about

�35

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Introduction

�36

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Quick History

�37

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Philosophy &

Purpose�38

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Major Changes

�39

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Architectural

�40

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

& API Changes

�41

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

What I am not talking about

�42

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Testing=Good

�43

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider�44

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider�44

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Use Minitest?

�45

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

✅Fantastic!

�46

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

❌That’s OK!

�47

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Informative

�48

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

🤜rspec🤛

�49

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider�50

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider�51

�i

meh

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

∀x: minitest(x) < rspec(x)

�52

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

∀x: minitest(time) < rspec(time)

�53

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

∀x: minitest(mem) < rspec(mem)

�54

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

∀x: minitest(users) < rspec(users)

�55

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

∀x: minitest(dl) < rspec(dl)

�56

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

At the end of the day

�57

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

I do NOT care, as long as you test.

�58

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

That Said...

�59

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Minitest is faster and more direct

�60

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

�61

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

What & Why

�62

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

∂�63

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Guided Read of Minitest

�64

http://confreaks.tv/videos/rubyconf2015-a-guided-read-of-minitest

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Writing a Test Framework

from Scratch�65

http://www.zenspider.com/presentations/2016-roa.html

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

what you’ll tell them

Presentation Sammich

�66

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Quick Introduction

�67

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Test Framework

�68

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Unit & Functional

�69

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

XUnit-StyleClassesMethods

Assertions�70

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Spec-Styledescribe blocks

it blocksexpectations

�71

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

HardwareAgnostic

Performance Testing

�72

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Stubs & Mocks

�73

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

TDD & BDD

�74

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Clean Architecture

�75

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Very Very Fast

�76

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Flexible Reporting

�77

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Extensible: 200+ Gems

�78

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

The Briefest History of Minitest

�79

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

😴

�80

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

2004 test/unit

�81

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

🤷

�82

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

22 files, ~2400 LOC, ~2500 flog

�83

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

5 Runners

�84

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

2 “Collectors”

�85

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

and ALL the pattern buzzwords

�86

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

template engine

�87

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

assert_block

�88

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Why?

�89

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Failure Driven

Development�90

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

~25 Projects

�91

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Best of All

�92

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Only 75 lines!

�93

at_exit { Test::Unit.autotest }

module Test class Assertion < Exception; end class Unit VERSION = "1.0.0" def self.autotest ObjectSpace.each_object(Class) do |klass| next unless klass < Test::Unit::TestCase inst = klass.new klass.public_instance_methods(true).each do |meth| next unless meth.index("test") == 0 begin inst.setup inst.send meth.intern inst.teardown rescue Exception => e print "\n", (Test::Assertion === e ? "Failure: " : "Error: ") puts "#{klass}.#{meth}: #{e}" puts e.backtrace end end end end end end

module Test class Unit class TestCase def setup; end def teardown; end def assert(test, msg="failed assertion (no message given)") raise Test::Assertion, msg unless test end def assert_equal(exp, act, msg=nil) assert exp == act, msg || "Expected #{act.inspect} to be equal to #{exp.inspect}" end def assert_in_delta(exp, act, delta, msg=nil) assert((exp.to_f - act.to_f).abs <= delta.to_f, msg || "Expected #{exp} to be within #{delta} of #{act}") end def assert_instance_of(cls, obj, msg=nil) assert cls === obj, msg || "Expected #{obj} to be a #{cls}" end def assert_kind_of(cls, obj, msg=nil) assert obj.kind_of?(cls), msg || "Expected #{obj.inspect} to be a kind of #{cls}" end def assert_match(exp, act, msg=nil) assert act =~ exp, msg || "Expected #{act.inspect} to match #{exp.inspect}" end def assert_nil(obj, msg=nil) assert obj.nil?, msg || "Expected #{obj.inspect} to be nil" end def assert_not_equal(exp, act, msg=nil) assert exp != act, msg || "Expected #{act.inspect} to not be equal to #{exp.inspect}" end def assert_not_nil(obj, msg=nil) assert ! obj.nil?, msg || "Expected #{obj.inspect} to not be nil" end def assert_not_same(exp, act, msg=nil) assert ! exp.equal?(act), msg || "Expected #{act.inspect} to not be the same as #{exp.inspect}" end def assert_raises(exp, msg=nil) yield assert false, "Expected #{exp} to be raised" rescue Exception => e assert exp === e, msg || "Expected #{exp} to be raised, but got #{e.class}" return e end alias :assert_raise :assert_raises def assert_same(exp, act, msg=nil) assert exp.equal?(act), msg || "Expected #{act.inspect} to be the same as #{exp.inspect}" end def assert_operator(o1, op, o2, msg="") assert o1.__send__(op, o2), msg || "Expected #{o1}.#{op}(#{o2}) to be true" end def assert_nothing_raised; yield; end end end end

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

History in a 🥜

�95

2006-10 1.0.0 Initial Release.2008-06 1.2.0 Full Assertions, Specs, and Mocks.2010-11 2.0.0 Benchmarks.2012-05 3.0.0 Stubs & other enhancements.2012-09 4.0.0 Nothing external. Internal name changes.2013-05 5.0.0 Huge overhaul. What I really wanted.2018-01 5.11.3 Current functionality. Expanded Reporters.

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

History in a 🥜

�95

2006-10 1.0.0 Initial Release.2008-06 1.2.0 Full Assertions, Specs, and Mocks.2010-11 2.0.0 Benchmarks.2012-05 3.0.0 Stubs & other enhancements.2012-09 4.0.0 Nothing external. Internal name changes.2013-05 5.0.0 Huge overhaul. What I really wanted.2018-01 5.11.3 Current functionality. Expanded Reporters.

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

History in a 🥜

�96

2006-10 1.0.0 Initial Release.2008-06 1.2.0 Full Assertions, Specs, and Mocks.2010-11 2.0.0 Benchmarks.2012-05 3.0.0 Stubs & other enhancements.2012-09 4.0.0 Nothing external. Internal name changes.2013-05 5.0.0 Huge overhaul. What I really wanted.2018-01 5.11.3 Current functionality. Expanded Reporters.

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider�97

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider�97

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Complexity Over Time

�98

0

750

1500

2250

300020

06

2007

2008

2009

2010

2011

2012

2013

2014

2015

2016

2017

2018

2019

1 1.2 2 34 5 5.116

VersionLOCFlog

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

0

4500

9000

13500

18000

2.0 3.0 3.5

FlogLOC rspec 2-3.5

�99

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

0

4500

9000

13500

18000

2.0 3.0 3.5

FlogLOC

minitest

rspec 2-3.5

�99

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Minitest Firsts

�100

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Shuffle tests by default

�101

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Test & Spec, TDD & BDD

�102

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Benchmark Tests

�103

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Purpose & Philosophy of

Minitest�104

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

I ❤ XP

�105

http://www.projectcartoon.com

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Test First

�106

http://wiki.c2.com/?CodeUnitTestFirst

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

DTSTTCPW “dut-st-t-cupwuh”???

�107

http://wiki.c2.com/?DoTheSimplestThingThatCouldPossiblyWork

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

YAGNI

�108

http://wiki.c2.com/?YouArentGonnaNeedIt

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Incredibly Simple

�109

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Learning Ruby is hard enough!

�110

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

🏃Takes a Lot=

�111

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

minitest? rspec? Beginner?

Magic!�112

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Ruby is Magic

�113

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

def is my stub frameworkthingy = Something.new

def thingy.expensive_value 42 end

# …write fast tests…

�114

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Less Magic

�115

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Framework < Learning

�116

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Expand Toolbox

�117

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Lower the Bar

�118

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Lower the BarClasses & Objects

�118

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Lower the BarClasses & ObjectsMethods & Method calls

�118

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Lower the BarClasses & ObjectsMethods & Method callsReading API Doco

�118

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Nothing Extra

�119

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Usable Tools

�120

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Minimal Testrequire "minitest/autorun" class TestCalculator < Minitest::Test def test_basics assert_equal 4, calculate("2+2") end end

�121

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Minimal Specrequire "minitest/autorun" describe Calculator do it "should handle the basics" do _(calculate "2+2").must_equal 4 end end

�122

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

1:1

�123

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

specs are tests

�124

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Just Ruby™

�125

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Just Use Ruby™

�126

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Incredibly Fast

�127

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Fastest Test

Framework�128

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

It achieves that by doing nothing extraMinitest.autorun Minitest.run(args) Minitest.__run(reporter, options) Runnable.runnables.each runnable.run(reporter, options) self.runnable_methods.each do |method| self.run_one_method(method, reporter) Minitest.run_one_method(klass, method) klass.new(runnable_method).run

�129

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider�130

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

(Almost) Nothing Extra

�131

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Store Nothing Extra

�132

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

GC

�133

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Don’t Create Extra Objects

�134

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Release ASAP

�135

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Memory = #tests

�136

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Memory = #failures

�137

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

rspec is nx

�138

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Pain = Slow

�139

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

RSpec ~30% slower on a

fast suite�140

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Improve Testing

�141

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider�142

Randomize Test Order

Require Assertion Call?

Incre

dibly

Fast

Tests

Parallelization by default

01

2

3

45

6 78

9

1011

Only meaningful assertions

Choice: tests or specs

Benchmark Tests

Test Driven Design Refac

tor A

sser

tions

Refactor Test Classes

???

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider�143

Randomize Test Order

Require Assertion Call?

Incre

dibly

Fast

Tests

Parallelization by default

01

2

3

45

6 78

9

1011

Only meaningful assertions

Choice: tests or specs

Benchmark Tests

Test Driven Design Refac

tor A

sser

tions

Refactor Test Classes

???

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider�144

Randomize Test Order

Require Assertion Call?

Incre

dibly

Fast

Tests

Parallelization by default

01

2

3

45

6 78

9

1011

Only meaningful assertions

Choice: tests or specs

Benchmark Tests

Test Driven Design Refac

tor A

sser

tions

Refactor Test Classes

???

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider�145

Randomize Test Order

Require Assertion Call?

Incre

dibly

Fast

Tests

Parallelization by default

01

2

3

45

6 78

9

1011

Only meaningful assertions

Choice: tests or specs

Benchmark Tests

Test Driven Design Refac

tor A

sser

tions

Refactor Test Classes

???

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider�146

Randomize Test Order

Require Assertion Call?

Incre

dibly

Fast

Tests

Parallelization by default

01

2

3

45

6 78

9

1011

Only meaningful assertions

Choice: tests or specs

Benchmark Tests

Test Driven Design Refac

tor A

sser

tions

Refactor Test Classes

???

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider�147

Randomize Test Order

Require Assertion Call?

Incre

dibly

Fast

Tests

Parallelization by default

01

2

3

45

6 78

9

1011

Only meaningful assertions

Choice: tests or specs

Benchmark Tests

Test Driven Design Refac

tor A

sser

tions

Refactor Test Classes

???

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider�148

Randomize Test Order

Require Assertion Call?

Incre

dibly

Fast

Tests

Parallelization by default

01

2

3

45

6 78

9

1011

Only meaningful assertions

Choice: tests or specs

Benchmark Tests

Test Driven Design Refac

tor A

sser

tions

Refactor Test Classes

???

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider�149

Randomize Test Order

Require Assertion Call?

Incre

dibly

Fast

Tests

Parallelization by default

01

2

3

45

6 78

9

1011

Only meaningful assertions

Choice: tests or specs

Benchmark Tests

Test Driven Design Refac

tor A

sser

tions

Refactor Test Classes

???

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider�150

Randomize Test Order

Require Assertion Call?

Incre

dibly

Fast

Tests

Parallelization by default

01

2

3

45

6 78

9

1011

Only meaningful assertions

Choice: tests or specs

Benchmark Tests

Test Driven Design Refac

tor A

sser

tions

Refactor Test Classes

???

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider�151

Randomize Test Order

Require Assertion Call?

Incre

dibly

Fast

Tests

Parallelization by default

01

2

3

45

6 78

9

1011

Only meaningful assertions

Choice: tests or specs

Benchmark Tests

Test Driven Design Refac

tor A

sser

tions

Refactor Test Classes

???

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider�152

Randomize Test Order

Require Assertion Call?

Incre

dibly

Fast

Tests

Parallelization by default

01

2

3

45

6 78

9

1011

Only meaningful assertions

Choice: tests or specs

Benchmark Tests

Test Driven Design Refac

tor A

sser

tions

Refactor Test Classes

???

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider�153

Randomize Test Order

Require Assertion Call?

Incre

dibly

Fast

Tests

Parallelization by default

01

2

3

45

6 78

9

1011

Only meaningful assertions

Choice: tests or specs

Benchmark Tests

Test Driven Design Refac

tor A

sser

tions

Refactor Test Classes

???

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Reproducibility

�154

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Reproducibility is

Paramount�155

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

--seed ###�156

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

--name /pattern/

�157

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

i_suck_and_my_tests_are_order_dependent!

�158

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

No (less?) Dogma

�159

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

I ❤ That!

�160

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Not for Everyone

�161

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Should It?

�162

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

For me:

�163

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Test First (red, green, refactor)

�164

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

DTSTTCPW

�165

(do the simplest thing that could possibly work)

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Mock Last

�166

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider�167

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Simple.

�167

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Simple.Statist.

�167

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Simple.Statist.Tests.

�167

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

“You should write a test for anything that could break”

—Kent Beck

�168

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Major MT5 Changes

�169

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Major namespace rename MiniTest::Unit::TestCase

-> Minitest::Test.

�170

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Added Minitest::Benchmark

�171

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

No Managers No Runners

�172

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider�173

MiniTest

MiniTest::Assertion

MiniTest::Unit::Guard

MiniTest::Assertions

MiniTest::Expectations

MiniTest::Unit::TestCase

MiniTest::Spec::DSL

MiniTest::Unit::LifecycleHooks

MiniTest::PrideIO

MiniTest::Unit

MiniTest::PrideLOL

MiniTest::Spec

MiniTest::Skip

Minitest::BacktraceFilter Minitest::ParallelEach Minitest::Mock

Minitest 4

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider�174

Minitest

Minitest::Runnable

Minitest::Reporter Minitest::Assertion

Minitest::Guard

Minitest::BacktraceFilter

Minitest::Assertions

Minitest::Expectations

Minitest::Test

Minitest::Benchmark Minitest::Spec::DSL

Minitest::Test::LifecycleHooks

Minitest::ParallelEach

Minitest::PrideIO

Minitest::PrideLOL

Minitest::BenchSpec

Minitest::Spec

Minitest::Skip Minitest::UnexpectedErrorMinitest::CompositeReporter

Minitest::Mock

Minitest 5

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider�175

MiniTest

Minitest::Runnable

Minitest::Reporter Minitest::Assertion

Minitest::Guard

Minitest::BacktraceFilter

Minitest::Assertions

Minitest::Expectations

Minitest::Test

Minitest::Benchmark Minitest::Spec::DSL

Minitest::Test::LifecycleHooks

Minitest::ParallelEach

Minitest::PrideIO

Minitest::PrideLOL

Minitest::BenchSpec

Minitest::Spec

Minitest::Skip Minitest::UnexpectedErrorMinitest::CompositeReporter

Minitest::Mock

MiniTest::Unit

MT4 -> MT5Minitest

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Major MT6 Changes

�176

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Architectural Changes in Minitest 6

�177

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Same Namespace!

�178

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Same Classes!

�179

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

No Cruft!

�180

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

5.12.0 MT5 w/ deprecations on. 5.11.x MT5 w/o deprecations.5.3.3 Un-shuffled test suites.

Compatibility Chart

�181

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Yeah Yeah

�182

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Parallelism

�183

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

parallelize_me!

�184

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Make parallel the default?

�185

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

serialize_me!

�186

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Testing @ Scale Implementations

That Scale�187

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

All Tests, Completely

Shuffled�188

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Distributed Testing

�189

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Distribute Locally

�190

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Use all your CPUs!

�191

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

jeremyevans/minitest-parallel_fork 2 forks 4 forks spec_core: 1.25x - 1.36x 1.5x spec_model: 1.29x - 1.62x 1.72x - 2.02x spec_plugin: 1.57x - 1.76x 2.29x - 2.37x spec_sqlite: 1.75x - 1.86x 2.26x - 2.65x spec_postgres: 1.32x - 1.40x Untested

�192

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Distribute Across VMs

�193

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Speed Up CI

�194

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Config? Setup?

�195

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Minitest will expect:SSH accessOpen ports (or tunneling?)Same source layout

�196

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Safe to Assume?

�197

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Distribution / Parallelism libraries:

tmm1/test-queuejeremyevans/minitest-parallel_forkArturT/knapsack

�198

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Serialization Guarantees

�199

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

No Marshal Code

�200

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Added Result

�201

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Disconnected from Test

�202

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Better Parallel & Distributed Testing

�203

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Better GC

�204

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Ruby 2.5 Exceptions?

�205

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

CleanerProject

�206

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Split Files

�207

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Cleaner Call Stack

�208

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Not Sure

�209

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Current StackMinitest.autorun Minitest.run(args) Minitest.__run(reporter, options) Runnable.runnables.each do |runnable| runnable.run(reporter, options) self.runnable_methods.each self.run_one_method(self, method, reporter) Minitest.run_one_method(klass, method) klass.new(runnable_method).run

�210

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Minor RefactoringMinitest.autorun Minitest.run(args) Minitest.__run(reporter, options) methods = filter Runnable.runnables methods.each do |runnable| runnable.run(reporter, options) self.runnable_methods.each self.run_one_method(self, method, reporter) Minitest.run_one_method(klass, method) klass.new(runnable_method).run

�211

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Dream RefactoringMinitest.autorun Minitest.run(args) Minitest.__run(reporter, options) methods = filter Runnable.runnables methods.shuffle.each do |(runnable, method)| runnable.run(reporter, options) self.runnable_methods.each self.run_one_method(self, method, reporter) Minitest.run_one_method(klass, method) klass.new(runnable_method).run

�212

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Dream VersionMinitest.autorun Minitest.run(args) Minitest.__run(reporter, options) methods = filter Runnable.runnables methods.shuffle.each do |(runnable, method)| runnable.run_one_method(self, method, reporter) Minitest.run_one_method(klass, method) klass.new(runnable_method).run

�213

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Too Far?

�214

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Parallel By Default

�215

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Powerful!

�216

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Problematic

�217

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

DB Testing (non-transactional)

�218

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Time.now�219

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Code Changes

�220

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

command-line runner

�221

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

bin/minitest

�222

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Better Integration eg: s/minitest/minitest_bisect/

�223

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Rake’s TestTask

�224

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

minitest/test.rake

�225

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Improved Mocks/Stubs

�226

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

stub w/ blocks

�227

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Adding fake?obj = fake a:42

assert_equal 42, obj.a

�228

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Too Simple?def fake attribs obj = Object.new attribs.each do |name, value| obj.define_singleton_method name do value end end obj end

�229

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Stricter and Better Assertions.

�230

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

assert_equal(nil, x) => Failure

�231

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

More Explicit Signals Intent

�232

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Fix Tautological

Tests�233

http://randycoulman.com/blog/2016/12/20/tautological-tests/

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Assertion Reuse

�234

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

assert_operator assert_predicate

call assert_respond_to

�235

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Better FailuresFailure: Expected X to respond to message.

instead of:

Error: NoMethodError (undefined method `message’ for #<X:Y>).

�236

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Better Failure Messages

�237

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Especially w/ layered assertions

�238

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Removed assert_send

�239

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Improved Specs

�240

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

No more expectations on Object- class Object # :nodoc: - include Minitest::Expectations unless ENV["MT_NO_EXPECTATIONS"] - end

�241

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Easy Conversion# beforeo.m.must_equal 42

# after_(o.m).must_equal 42

�242

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Easy Conversion# beforeo.m.must_equal 42

# after_(o.m).must_equal 42value(o.m).must_equal 42 # or

�242

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Easy Conversion# beforeo.m.must_equal 42

# after_(o.m).must_equal 42value(o.m).must_equal 42 # orexpect(o.m).must_equal 42 # ugh

�242

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Much Cleaner

�243

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Closing

�244

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Introduction History

Philosophy�245

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Major Changes

�246

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Architectural

�247

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Parallelism

�248

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Distributed Testing &

Serialization�249

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Call Stack

�250

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Code Changes

�251

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

bin/minitest

�252

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

minitest/test.rake

�253

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

minitest/mock

�254

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Improved Assertions

�255

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Cleaner Specs

�256

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider�257

Randomize Test Order

Require Assertion Call?

Incre

dibly

Fast

Tests

Parallelization by default

01

2

3

45

6 78

9

1011

Only meaningful assertions

Choice: tests or specs

Benchmark Tests

Test Driven Design Refac

tor A

sser

tions

Refactor Test Classes

Distributed Testing

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider�258

https://xkcd.com/670/

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

That’s It!

�259

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Schedule?

�260

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Schedule?Unknown!

�260

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Schedule?Unknown!

Soon?!?�260

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Weeks to months

�261

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Not Longer (I hope?)

�262

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

I could use feedback and help!

�263

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Current draft is available at https://github.com/zenspider/minitest

on the mt6 branch.�264

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Thank You

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Thank YouIf you want to sponsor my work on Open Source:

Minitest 6: Test Feistier!

RailsConf 2018, Pittsburgh, PA

Ryan Davis, Seattle.rb 

@the_zenspider

Thank YouIf you want to sponsor my work on Open Source:

https://www.patreon.com/zenspider

Recommended