continuous testing

48
Continuous Testing Eric Hogue @ehogue erichogue.ca TrueNorth <?PHP?> Uncon November 9, 2013

Upload: eric-hogue

Post on 15-Jan-2015

1.288 views

Category:

Technology


2 download

DESCRIPTION

A talk on continuous testing in PHP I gave at the uncon of True North PHP 2013.

TRANSCRIPT

Page 1: Continuous Testing

Continuous TestingEric Hogue

@ehogueerichogue.ca

TrueNorth <?PHP?> UnconNovember 9, 2013

Page 2: Continuous Testing

Continuous Testing

Page 3: Continuous Testing

How I Discovered it

Photo: Morten Diesenhttp://www.flickr.com/photos/mortendiesen/8091682612

Page 4: Continuous Testing

TDD

Photo: William Warbyhttp://www.flickr.com/photos/wwarby/2460655511

Page 5: Continuous Testing

Photo: ser... ser...http://www.flickr.com/photos/el_ser_lomo/3267627038

Page 6: Continuous Testing

Automate the

Automated Tests

Photo: Markushttp://www.flickr.com/photos/tschiae/9758986651/

Page 7: Continuous Testing

Feedback

Page 8: Continuous Testing

Photo: Jeffrey Beallhttp://www.flickr.com/photos/denverjeffrey/5133538450/

Page 9: Continuous Testing

Guard

Page 10: Continuous Testing

Plugins

Page 11: Continuous Testing

Guard::PHPUnit2

Page 12: Continuous Testing

Installation

Page 13: Continuous Testing

Gemfile

source 'https://rubygems.org'group :development do gem 'guard' gem 'guard-phpunit2' end

Installation

Page 14: Continuous Testing

Gemfile

source 'https://rubygems.org'group :development do gem 'guard' gem 'guard-phpunit2' end

$ bundle install

Installation

Page 15: Continuous Testing

$ bundle exec guard

Page 16: Continuous Testing

$ bundle exec guard

Page 17: Continuous Testing

guard 'phpunit2', :cli => '--colors' do watch(%r{^.+Test\.php$}) end

Guardfile

Page 18: Continuous Testing
Page 19: Continuous Testing

guard 'phpunit2', :cli => '--colors' do watch(%r{^tests/.+Test\.php$})

watch(%r{^src/(.+)\.php$}) { |m|"tests/#{m[1]}Test.php"

}end

Page 20: Continuous Testing

%r{^src/(.+)\.php$}src/TDD/Factorial.php

Page 21: Continuous Testing

%r{^src/(.+)\.php$}src/TDD/Factorial.php

"tests/#{m[1]}Test.php"phpunit tests/TDD/FactorialTest.php

Page 22: Continuous Testing

SettingsPhoto: Luis Humberto Molinar Márquezhttp://www.flickr.com/photos/anktsunamunh/3271371910/

Page 23: Continuous Testing

:all_on_start => true

Page 24: Continuous Testing

:all_after_pass => true

Page 25: Continuous Testing

:keep_failed => true

Page 26: Continuous Testing
Page 27: Continuous Testing

Gemfilegem 'guard-phpcs'

Guardfileguard 'phpcs', :standard => 'PSR2' do

watch(%r{.*\.php$})end

Guard::PHPCS

Page 28: Continuous Testing
Page 29: Continuous Testing

Gemfilegem 'guard-phpmd'

Guardfileguard 'phpmd' do

watch(%r{.*\.php$})end

Guard::PHPMD

Page 30: Continuous Testing
Page 31: Continuous Testing

Guard::ShellGemfilegem 'guard-shell'

Guardfileguard 'shell' do watch(%r{^.+\.php$}) {|m| `php -l #{m[0]}` true

}end

Page 32: Continuous Testing

Guard::Shell

Page 33: Continuous Testing

Other Guards

Page 34: Continuous Testing

module ::Guardclass Behat < Guardend

end

Inline Guard

Page 35: Continuous Testing

def start puts 'Run all Behat tests'puts `bin/behat --format progress`

end

Page 36: Continuous Testing

def run_on_change(paths)paths.each do |file|

puts "Running behat on #{file}"

puts `bin/behat #{file} --format progress`

endend

Page 37: Continuous Testing

guard 'behat' dowatch %r{^features/.+\.feature$}

end

Page 38: Continuous Testing
Page 39: Continuous Testing
Page 40: Continuous Testing

Notifi

catio

ns

Photo: Ben Schuminhttp://www.flickr.com/photos/schuminweb/9806474636/

Page 41: Continuous Testing

Gemfilegem 'libnotify'

Guardfile# Linuxnotification :libnotify

# Macnotification :growl

Libnotify/Growl

Page 42: Continuous Testing
Page 43: Continuous Testing

notification :terminal_title

Console Title

Page 44: Continuous Testing

notification :terminal_title

Console Title

Page 45: Continuous Testing

notification :tmux, :default_message_format => '%s >> %s', :line_separator => ' > ', :color_location => 'status-left-bg'

tmux

Page 46: Continuous Testing

notification :off

Page 47: Continuous Testing

Guard

Page 48: Continuous Testing

Comments:https://joind.in/10013

Twitter:@ehogue

Blog:http://erichogue.ca/

Questions

Damián Navashttp://www.flickr.com/photos/wingedwolf/5471047557/