continuous testing
DESCRIPTION
A talk on continuous testing in PHP I gave at the uncon of True North PHP 2013.TRANSCRIPT
Continuous TestingEric Hogue
@ehogueerichogue.ca
TrueNorth <?PHP?> UnconNovember 9, 2013
Continuous Testing
How I Discovered it
Photo: Morten Diesenhttp://www.flickr.com/photos/mortendiesen/8091682612
TDD
Photo: William Warbyhttp://www.flickr.com/photos/wwarby/2460655511
Photo: ser... ser...http://www.flickr.com/photos/el_ser_lomo/3267627038
Automate the
Automated Tests
Photo: Markushttp://www.flickr.com/photos/tschiae/9758986651/
Feedback
Photo: Jeffrey Beallhttp://www.flickr.com/photos/denverjeffrey/5133538450/
Guard
Plugins
Guard::PHPUnit2
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
Installation
$ bundle exec guard
$ bundle exec guard
guard 'phpunit2', :cli => '--colors' do watch(%r{^.+Test\.php$}) end
Guardfile
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
SettingsPhoto: Luis Humberto Molinar Márquezhttp://www.flickr.com/photos/anktsunamunh/3271371910/
:all_on_start => true
:all_after_pass => true
:keep_failed => true
Gemfilegem 'guard-phpcs'
Guardfileguard 'phpcs', :standard => 'PSR2' do
watch(%r{.*\.php$})end
Guard::PHPCS
Gemfilegem 'guard-phpmd'
Guardfileguard 'phpmd' do
watch(%r{.*\.php$})end
Guard::PHPMD
Guard::ShellGemfilegem 'guard-shell'
Guardfileguard 'shell' do watch(%r{^.+\.php$}) {|m| `php -l #{m[0]}` true
}end
Guard::Shell
Other Guards
module ::Guardclass Behat < Guardend
end
Inline Guard
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`
endend
guard 'behat' dowatch %r{^features/.+\.feature$}
end
Notifi
catio
ns
Photo: Ben Schuminhttp://www.flickr.com/photos/schuminweb/9806474636/
Gemfilegem 'libnotify'
Guardfile# Linuxnotification :libnotify
# Macnotification :growl
Libnotify/Growl
notification :terminal_title
Console Title
notification :terminal_title
Console Title
notification :tmux, :default_message_format => '%s >> %s', :line_separator => ' > ', :color_location => 'status-left-bg'
tmux
notification :off
Guard
Comments:https://joind.in/10013
Twitter:@ehogue
Blog:http://erichogue.ca/
Questions
Damián Navashttp://www.flickr.com/photos/wingedwolf/5471047557/