Continuous Testing
Eric Hogue
@ehogue
erichogue.ca

TrueNorth <?PHP?> Uncon
November 9, 2013
Cont
inuo
us
Test
ing
How
Dis
I
cov
ere
d it

Photo: Morten Diesen
http://www.flickr.com/photos/mortendiesen/8091682612
DD
T

Photo: William Warby
http://www.flickr.com/photos/wwarby/2460655511
Photo: ser... ser...
http://www.flickr.com/photos/el_ser_lomo/3267627038
Au
to
Au ma
to te
m
Te at the
sts ed

Photo: Markus
http://www.flickr.com/photos/tschiae/9758986651/
ed
Fe

ck
ba
Photo: Jeffrey Beall
http://www.flickr.com/photos/denverjeffrey/5133538450/
G

rd
ua
lu
P

ns
gi
Guard::PHPUnit2
Installation
Installation
Gemfile
source 'https://rubygems.org'
group :development do
gem 'guard'
gem 'guard-phpunit2'
end
Installation
Gemfile
source 'https://rubygems.org'
group :development do
gem 'guard'
gem 'guard-phpunit2'
end
$ bundle install
$ bundle exec guard
$ bundle exec guard
Guardfile
guard 'phpunit2', :cli => '--colors' do
watch(%r{^.+Test.php$})
end
guard 'phpunit2', :cli => '--colors' do
watch(%r{^tests/.+Test.php$})
watch(%r{^src/(.+).php$}) { |m|
"tests/#{m[1]}Test.php"
}
end
%r{^src/(.+).php$}
src/TDD/Factorial.php
%r{^src/(.+).php$}
src/TDD/Factorial.php

"tests/#{m[1]}Test.php"
phpunit tests/TDD/FactorialTest.php
Photo: Luis Humberto Molinar Márquez
http://www.flickr.com/photos/anktsunamunh/3271371910/

gs
tin
et
S
:all_on_start => true
:all_after_pass => true
:keep_failed => true
Guard::PHPCS
Gemfile
gem 'guard-phpcs'
Guardfile
guard 'phpcs', :standard => 'PSR2' do
watch(%r{.*.php$})
end
Guard::PHPMD
Gemfile
gem 'guard-phpmd'
Guardfile
guard 'phpmd' do
watch(%r{.*.php$})
end
Guard::Shell
Gemfile
gem 'guard-shell'
Guardfile
guard 'shell' do
watch(%r{^.+.php$}) {|m|
`php -l #{m[0]}`
true
}
end
Guard::Shell
Ot
Gu her
ar
ds
Inline Guard
module ::Guard
class Behat < Guard
end
end
def start
puts 'Run all Behat tests'
puts `bin/behat --format progress`
end
def run_on_change(paths)
paths.each do |file|
puts "Running behat on #{file}"
puts `bin/behat #{file} --format
progress`
end
end
guard 'behat' do
watch %r{^features/.+.feature$}
end
s
n

io
t
a
c

fi
ti

Photo: Ben Schumin
http://www.flickr.com/photos/schuminweb/9806474636/

o
N
Libnotify/Growl
Gemfile
gem 'libnotify'
Guardfile
# Linux
notification :libnotify
# Mac
notification :growl
Console Title
notification :terminal_title
Console Title
notification :terminal_title
tmux
notification :tmux,
:default_message_format => '%s >> %s',
:line_separator => ' > ',
:color_location => 'status-left-bg'
notification :off
G

rd
ua
Questions
Comments:
https://joind.in/10013
Twitter:
@ehogue
Blog:
http://erichogue.ca/
Damián Navas
http://www.flickr.com/photos/wingedwolf/5471047557/

Continuous Testing