SlideShare a Scribd company logo
1 of 41
Download to read offline
Turbo Charged
                            Test Suites



Tuesday, 7 October 2008
Curtis “Ovid” Poe

                    • CPAN Author
                    • “Perl Hacks” Contributor
                    • Perl Foundation Member


Tuesday, 7 October 2008
Test Suite Performance


                    • Computer
                    • Developer


Tuesday, 7 October 2008
Faster Tests




Tuesday, 7 October 2008
Considerations


                    • Why speed things up?
                    • Trade-offs


Tuesday, 7 October 2008
Before You Start

                    • Set a goal
                    • No tests may fail
                    • No non-test output


Tuesday, 7 October 2008
Databases


                    • Don’t drop them
                    • Don’t fake it with transactions


Tuesday, 7 October 2008
Databases


                    • Static tables -- country_codes
                    • Dynamic tables -- orders


Tuesday, 7 October 2008
CREATE TABLE changed_table (
                    changed_table_id INT(11)
                      NOT NULL AUTO_INCREMENT PRIMARY KEY,
                    table_name       VARCHAR(30) NOT NULL,
                    is_static        INT NOT NULL DEFAULT 0,
                    inserts          INT NOT NULL DEFAULT 0,
                    updates          INT NOT NULL DEFAULT 0,
                    deletes          INT NOT NULL DEFAULT 0
                )

                -- then insert table records




Tuesday, 7 October 2008
foreach my $action (qw/insert update delete/) {
                    $dbh->do(<<quot;    END_SQLquot;);
                    CREATE TRIGGER tr_${action}_$table
                      BEFORE $action ON $table
                    FOR EACH ROW UPDATE changed_table
                      SET ${action}s = ${action}s + 1
                      WHERE table_name = '$table';
                    END_SQL
                }




Tuesday, 7 October 2008
db.disable_foreign_keys()
                for table in changed_tables()
                  table.truncate()
                  if table.is_static()
                    table.rebuild()
                db.enable_foreign_keys()




Tuesday, 7 October 2008
Databases


                    • Before: 80 minutes
                    • After: 22 minutes


Tuesday, 7 October 2008
Aggregation


                    • Only load things once
                    • Dangers of shared state


Tuesday, 7 October 2008
use My::YAML::Test;
                My::YAML::Test->run;
                # t/api/customer.t
                # t/api/customer.yml




Tuesday, 7 October 2008
use My::YAML::Test;
                foreach (yaml_tests()) {
                    diag “running $_”;
                    My::YAML::Test->run($_);
                }

                sub yaml_tests {
                    return @ARGV if @ARGV;
                    # or return all YAML files ...
                }




Tuesday, 7 October 2008
YAML Aggregation


                    • Before: 22 minutes
                    • After: 16 minutes


Tuesday, 7 October 2008
use Test::Aggregate;
                my $tests = Test::Aggregate->new({
                    dirs => ‘aggtests’,
                });
                $tests->run;




Tuesday, 7 October 2008
use Test::Aggregate;
                my $tests = Test::Aggregate->new({
                    dirs          => 'aggtests',
                    dump          => $dump,
                    set_filenames => 1,
                    shuffle       => 1,
                    startup       => &startup,
                    shutdown      => &shutdown,
                });




Tuesday, 7 October 2008
Generic Aggregation


                    • Before: 16 minutes
                    • After: 12 minutes


Tuesday, 7 October 2008
Better Aggregation


                    • use Test::Class



Tuesday, 7 October 2008
OK to Fail is OK

                    • POD tests
                    • Perl::Critic
                    • Anything “non-functional”


Tuesday, 7 October 2008
OK to Fail is OK


                    • Move them to xt/
                    • But they must be run!


Tuesday, 7 October 2008
Lessons Learned

                    • Not dropping your database is tricky
                    • Aggregating tests finds bugs in tests
                    • Aggregating tests finds bugs in code
                    • *CORE::GLOBAL:: is evil
                    • Don’t touch UNIVERSAL::

Tuesday, 7 October 2008
Faster Programmers




Tuesday, 7 October 2008
Custom Test Modules




Tuesday, 7 October 2008
use       Test::More tests => 13;
                use       Test::Exception;
                use       Test::XML;
                use       Test::JSON;
                use       Test::Differences;




Tuesday, 7 October 2008
package Our::Test::More;

                use       Test::Builder::Module;
                our       ( @ISA, @EXPORT );
                use       Test::More;
                use       Test::Exception;

                BEGIN {
                    @ISA = qw(Test::Builder::Module);
                    @EXPORT = (
                        @Test::More::EXPORT,
                        @Test::Exception::EXPORT,
                    );
                }

                1;


Tuesday, 7 October 2008
package My::Custom::Tests;

                use Test::Kit (
                    'Test::More',
                    'Test::XML',
                    'Test::Differences',
                    '+explain',
                );

                1;




Tuesday, 7 October 2008
Popularity Contest
                           Test::More              44461
                           Test                     8937
                           Test::Exception          1397
                           Test::Simple              731
                           Test::Base                316
                           Test::Builder::Tester     193
                           Test::NoWarnings          174
                           Test::Differences         146
                           Test::MockObject          139
                           Test::Deep                127



Tuesday, 7 October 2008
use Test::Most tests => 4, 'die';

                ok 1,    'one is true';
                is 2, 2, '... and two is two';
                eq_or_diff [3], [4],
                 “... but three ain’t four”;
                throws_ok { $foo/0 }
                 qr/Illegal division by zero/,
                 'and no-constant folding with vars';




Tuesday, 7 October 2008
Test From Your Editor




Tuesday, 7 October 2008
“ in your .vimrc

                function! PerlMappings()
                    noremap K :!perldoc <cword> <bar><bar> 
                        perldoc -f <cword><cr>
                endfunction

                function! PerlTestMappings()
                    noremap <buffer> ,t :!prove -vl %<CR>
                endfunction

                “ remember My::Test::YAML?
                function! YAMLTestMappings()
                    noremap <buffer> ,t :!prove -vl t/yaml.t :: %<CR>
                endfunction

                au! FileType perl          :call PerlMappings()
                au! FileType yaml          :call YAMLTestMappings()
                au! BufRead,BufNewFile *.t :call PerlTestMappings()




Tuesday, 7 October 2008
vim $(ack -l --perl 'api/v1/episode' t/)



                map <leader>tb :call RunTestsInBuffers()<cr>
                function! RunTestsInBuffers()
                    let i = 1
                    let tests = ''
                    while (i <= bufnr(quot;$quot;))
                         let filename = bufname(i)
                         if match(filename, '.t$') > -1
                             let tests = tests . ' quot;' . filename . 'quot;'
                         endif
                         let i = i+1
                    endwhile
                    if !strlen(tests)
                         echo quot;No tests found in buffersquot;
                    else
                         execute ':!prove ' . tests
                    endif
                endfunction




Tuesday, 7 October 2008
Advanced “prove”




Tuesday, 7 October 2008
Test-Harness $ prove -l t --state=hot,fast,save   --timer
                [20:57:19] t/yamlish-output.........ok       40   ms
                [20:57:20] t/console................ok       45   ms
                [20:57:20] t/utils..................ok       48   ms
                <snip>
                [20:57:23] t/harness................ok      300   ms
                [20:57:23] t/process................ok     1020   ms
                [20:57:24] t/prove..................ok     1017   ms
                [20:57:25] t/regression.............ok     4217   ms
                [20:57:29]
                All tests successful.
                Files=32, Tests=10326, 10 wallclock secs ( 1.25   usr
                0.24 sys + 5.60 cusr 1.83 csys = 8.92 CPU)
                Result: PASS




Tuesday, 7 October 2008
Test-Harness $ prove -l t --state=hot,slow,save -j 9
                t/callbacks.............. ok
                t/nofork................. ok
                t/proverc................ ok
                <snip>
                t/yamlish................ ok
                t/prove.................. ok
                t/regression............. ok
                All tests successful.
                Files=32, Tests=10326, 6 wallclock secs ( 1.34 usr
                0.24 sys + 5.63 cusr 1.83 csys = 9.04 CPU)
                Result: PASS




Tuesday, 7 October 2008
# slow running tests from App::Prove::State
                # http://use.perl.org/~Ovid/journal/35831

                Generation 18
                Number of test programs: 58
                Total runtime approximately 17 minutes 35 seconds
                Five slowest tests:
                        482.7 seconds -> t/acceptance.t
                        234.4 seconds -> t/aggregate.t
                        96.3 seconds -> t/standards/strict.t
                        66.6 seconds -> t/unit/db/migrations.t
                        56.7 seconds -> t/unit/piptest/pprove/testdb.t




Tuesday, 7 October 2008
Devel::CoverX::Covered




Tuesday, 7 October 2008
Devel::CoverX::Covered

                    • What tests cover this file?
                    • What files are covered by this test?
                    • (Soon) What tests cover this line?
                    • (Soon) What tests cover this subroutine?
                    • ... and more ...

Tuesday, 7 October 2008
function! PerlMappings()
                  noremap <buffer> ,cv :call Coverage()<cr>
                endfunction

                function! PerlTestMappings()
                  noremap <buffer> ,t :!prove -vl --norc %<CR>
                endfunction

                function! Coverage()
                  let file = bufname('%')
                  if match(filename, '.t$') > -1
                    execute '!covered by --test_file=quot;'.file.'quot;'
                  else
                    execute '!covered covering --source_file=quot;'.file.'quot;'
                  end
                endfunction

                au! FileType perl          :call PerlMappings()
                au! BufRead,BufNewFile *.t :call PerlTestMappings()




Tuesday, 7 October 2008
Questions?




Tuesday, 7 October 2008

More Related Content

What's hot

Dependency Injection with CDI in 15 minutes
Dependency Injection with CDI in 15 minutesDependency Injection with CDI in 15 minutes
Dependency Injection with CDI in 15 minutesAntonio Goncalves
 
To inject or not to inject: CDI is the question
To inject or not to inject: CDI is the questionTo inject or not to inject: CDI is the question
To inject or not to inject: CDI is the questionAntonio Goncalves
 
The Ring programming language version 1.10 book - Part 12 of 212
The Ring programming language version 1.10 book - Part 12 of 212The Ring programming language version 1.10 book - Part 12 of 212
The Ring programming language version 1.10 book - Part 12 of 212Mahmoud Samir Fayed
 
Software Testing - Invited Lecture at UNSW Sydney
Software Testing - Invited Lecture at UNSW SydneySoftware Testing - Invited Lecture at UNSW Sydney
Software Testing - Invited Lecture at UNSW Sydneyjulien.ponge
 
Demystifying dependency Injection: Dagger and Toothpick
Demystifying dependency Injection: Dagger and ToothpickDemystifying dependency Injection: Dagger and Toothpick
Demystifying dependency Injection: Dagger and ToothpickDanny Preussler
 
Tests unitaires mock_kesako_20130516
Tests unitaires mock_kesako_20130516Tests unitaires mock_kesako_20130516
Tests unitaires mock_kesako_20130516SOAT
 
Spocktacular Testing
Spocktacular TestingSpocktacular Testing
Spocktacular TestingRussel Winder
 
Construire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleConstruire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleThierry Wasylczenko
 
Parsing with Perl6 Grammars
Parsing with Perl6 GrammarsParsing with Perl6 Grammars
Parsing with Perl6 Grammarsabrummett
 
Groovy And Grails JUG Trento
Groovy And Grails JUG TrentoGroovy And Grails JUG Trento
Groovy And Grails JUG TrentoJohn Leach
 
Groovy And Grails JUG Sardegna
Groovy And Grails JUG SardegnaGroovy And Grails JUG Sardegna
Groovy And Grails JUG SardegnaJohn Leach
 
Innovative Specifications for Better Performance Logging and Monitoring
Innovative Specifications for Better Performance Logging and MonitoringInnovative Specifications for Better Performance Logging and Monitoring
Innovative Specifications for Better Performance Logging and MonitoringCary Millsap
 
Testing persistence in PHP with DbUnit
Testing persistence in PHP with DbUnitTesting persistence in PHP with DbUnit
Testing persistence in PHP with DbUnitPeter Wilcsinszky
 
15 tips to improve your unit tests (Droidcon Berlin 2016 Barcamp)
15 tips to improve your unit tests (Droidcon Berlin 2016 Barcamp)15 tips to improve your unit tests (Droidcon Berlin 2016 Barcamp)
15 tips to improve your unit tests (Droidcon Berlin 2016 Barcamp)Danny Preussler
 
33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good TestsTomek Kaczanowski
 

What's hot (20)

Dependency Injection with CDI in 15 minutes
Dependency Injection with CDI in 15 minutesDependency Injection with CDI in 15 minutes
Dependency Injection with CDI in 15 minutes
 
To inject or not to inject: CDI is the question
To inject or not to inject: CDI is the questionTo inject or not to inject: CDI is the question
To inject or not to inject: CDI is the question
 
Hidden rocks in Oracle ADF
Hidden rocks in Oracle ADFHidden rocks in Oracle ADF
Hidden rocks in Oracle ADF
 
The Ring programming language version 1.10 book - Part 12 of 212
The Ring programming language version 1.10 book - Part 12 of 212The Ring programming language version 1.10 book - Part 12 of 212
The Ring programming language version 1.10 book - Part 12 of 212
 
Guice2.0
Guice2.0Guice2.0
Guice2.0
 
Software Testing - Invited Lecture at UNSW Sydney
Software Testing - Invited Lecture at UNSW SydneySoftware Testing - Invited Lecture at UNSW Sydney
Software Testing - Invited Lecture at UNSW Sydney
 
Demystifying dependency Injection: Dagger and Toothpick
Demystifying dependency Injection: Dagger and ToothpickDemystifying dependency Injection: Dagger and Toothpick
Demystifying dependency Injection: Dagger and Toothpick
 
Tests unitaires mock_kesako_20130516
Tests unitaires mock_kesako_20130516Tests unitaires mock_kesako_20130516
Tests unitaires mock_kesako_20130516
 
Spocktacular Testing
Spocktacular TestingSpocktacular Testing
Spocktacular Testing
 
Construire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleConstruire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradle
 
Parsing with Perl6 Grammars
Parsing with Perl6 GrammarsParsing with Perl6 Grammars
Parsing with Perl6 Grammars
 
Groovy And Grails JUG Trento
Groovy And Grails JUG TrentoGroovy And Grails JUG Trento
Groovy And Grails JUG Trento
 
CDI: How do I ?
CDI: How do I ?CDI: How do I ?
CDI: How do I ?
 
#JavaFX.forReal() - ElsassJUG
#JavaFX.forReal() - ElsassJUG#JavaFX.forReal() - ElsassJUG
#JavaFX.forReal() - ElsassJUG
 
Groovy And Grails JUG Sardegna
Groovy And Grails JUG SardegnaGroovy And Grails JUG Sardegna
Groovy And Grails JUG Sardegna
 
Innovative Specifications for Better Performance Logging and Monitoring
Innovative Specifications for Better Performance Logging and MonitoringInnovative Specifications for Better Performance Logging and Monitoring
Innovative Specifications for Better Performance Logging and Monitoring
 
Code Samples
Code SamplesCode Samples
Code Samples
 
Testing persistence in PHP with DbUnit
Testing persistence in PHP with DbUnitTesting persistence in PHP with DbUnit
Testing persistence in PHP with DbUnit
 
15 tips to improve your unit tests (Droidcon Berlin 2016 Barcamp)
15 tips to improve your unit tests (Droidcon Berlin 2016 Barcamp)15 tips to improve your unit tests (Droidcon Berlin 2016 Barcamp)
15 tips to improve your unit tests (Droidcon Berlin 2016 Barcamp)
 
33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests
 

Similar to Turbo Charged Test Suites

Johnson at RubyConf 2008
Johnson at RubyConf 2008Johnson at RubyConf 2008
Johnson at RubyConf 2008jbarnette
 
Creating a Web of Data with Restlet
Creating a Web of Data with RestletCreating a Web of Data with Restlet
Creating a Web of Data with Restletguest7d0e11
 
Magento Imagine eCommerce Conference - February 2011 - Unit Testing with Magento
Magento Imagine eCommerce Conference - February 2011 - Unit Testing with MagentoMagento Imagine eCommerce Conference - February 2011 - Unit Testing with Magento
Magento Imagine eCommerce Conference - February 2011 - Unit Testing with Magentovarien
 
Magento's Imagine eCommerce Conference 2011 - Unit Testing with Magento
Magento's Imagine eCommerce Conference 2011 - Unit Testing with MagentoMagento's Imagine eCommerce Conference 2011 - Unit Testing with Magento
Magento's Imagine eCommerce Conference 2011 - Unit Testing with MagentoMagentoImagine
 
Building Web Sites With Movable Type
Building Web Sites With Movable TypeBuilding Web Sites With Movable Type
Building Web Sites With Movable TypeByrne Reese
 
Test Infected Presentation
Test Infected PresentationTest Infected Presentation
Test Infected Presentationwillmation
 
Scalable JavaScript
Scalable JavaScriptScalable JavaScript
Scalable JavaScriptYnon Perek
 
From typing the test to testing the type
From typing the test to testing the typeFrom typing the test to testing the type
From typing the test to testing the typeWim Godden
 
JSUG - Java FX by Christoph Pickl
JSUG - Java FX by Christoph PicklJSUG - Java FX by Christoph Pickl
JSUG - Java FX by Christoph PicklChristoph Pickl
 
Unit testing: unitils & dbmaintain
Unit testing: unitils & dbmaintainUnit testing: unitils & dbmaintain
Unit testing: unitils & dbmaintainnevenfi
 
Quality assurance in distributed continuous delivery
Quality assurance in distributed continuous deliveryQuality assurance in distributed continuous delivery
Quality assurance in distributed continuous deliverymingjin
 
Groovier Selenium (Djug)
Groovier Selenium (Djug)Groovier Selenium (Djug)
Groovier Selenium (Djug)Frederic Jean
 
Developer Tests - Things to Know (Vilnius JUG)
Developer Tests - Things to Know (Vilnius JUG)Developer Tests - Things to Know (Vilnius JUG)
Developer Tests - Things to Know (Vilnius JUG)vilniusjug
 

Similar to Turbo Charged Test Suites (20)

What Is Security
What Is SecurityWhat Is Security
What Is Security
 
Johnson at RubyConf 2008
Johnson at RubyConf 2008Johnson at RubyConf 2008
Johnson at RubyConf 2008
 
Creating a Web of Data with Restlet
Creating a Web of Data with RestletCreating a Web of Data with Restlet
Creating a Web of Data with Restlet
 
Magento Imagine eCommerce Conference - February 2011 - Unit Testing with Magento
Magento Imagine eCommerce Conference - February 2011 - Unit Testing with MagentoMagento Imagine eCommerce Conference - February 2011 - Unit Testing with Magento
Magento Imagine eCommerce Conference - February 2011 - Unit Testing with Magento
 
Magento's Imagine eCommerce Conference 2011 - Unit Testing with Magento
Magento's Imagine eCommerce Conference 2011 - Unit Testing with MagentoMagento's Imagine eCommerce Conference 2011 - Unit Testing with Magento
Magento's Imagine eCommerce Conference 2011 - Unit Testing with Magento
 
Building Web Sites With Movable Type
Building Web Sites With Movable TypeBuilding Web Sites With Movable Type
Building Web Sites With Movable Type
 
Test Infected Presentation
Test Infected PresentationTest Infected Presentation
Test Infected Presentation
 
Scalable JavaScript
Scalable JavaScriptScalable JavaScript
Scalable JavaScript
 
Intro To Grails
Intro To GrailsIntro To Grails
Intro To Grails
 
From typing the test to testing the type
From typing the test to testing the typeFrom typing the test to testing the type
From typing the test to testing the type
 
Testing in go
Testing in goTesting in go
Testing in go
 
Software Testing
Software TestingSoftware Testing
Software Testing
 
JSUG - Java FX by Christoph Pickl
JSUG - Java FX by Christoph PicklJSUG - Java FX by Christoph Pickl
JSUG - Java FX by Christoph Pickl
 
Test Automation Using Googletest
Test Automation Using GoogletestTest Automation Using Googletest
Test Automation Using Googletest
 
Unit testing: unitils & dbmaintain
Unit testing: unitils & dbmaintainUnit testing: unitils & dbmaintain
Unit testing: unitils & dbmaintain
 
Test driven development_for_php
Test driven development_for_phpTest driven development_for_php
Test driven development_for_php
 
Quality assurance in distributed continuous delivery
Quality assurance in distributed continuous deliveryQuality assurance in distributed continuous delivery
Quality assurance in distributed continuous delivery
 
Building Blueprint With Gwt
Building Blueprint With GwtBuilding Blueprint With Gwt
Building Blueprint With Gwt
 
Groovier Selenium (Djug)
Groovier Selenium (Djug)Groovier Selenium (Djug)
Groovier Selenium (Djug)
 
Developer Tests - Things to Know (Vilnius JUG)
Developer Tests - Things to Know (Vilnius JUG)Developer Tests - Things to Know (Vilnius JUG)
Developer Tests - Things to Know (Vilnius JUG)
 

More from Curtis Poe

How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
life-off-earth.pptx
life-off-earth.pptxlife-off-earth.pptx
life-off-earth.pptxCurtis Poe
 
Corinna-2023.pptx
Corinna-2023.pptxCorinna-2023.pptx
Corinna-2023.pptxCurtis Poe
 
Corinna Status 2022.pptx
Corinna Status 2022.pptxCorinna Status 2022.pptx
Corinna Status 2022.pptxCurtis Poe
 
Rummaging in the clOOset
Rummaging in the clOOsetRummaging in the clOOset
Rummaging in the clOOsetCurtis Poe
 
Rescuing a-legacy-codebase
Rescuing a-legacy-codebaseRescuing a-legacy-codebase
Rescuing a-legacy-codebaseCurtis Poe
 
Perl 6 For Mere Mortals
Perl 6 For Mere MortalsPerl 6 For Mere Mortals
Perl 6 For Mere MortalsCurtis Poe
 
Disappearing Managers, YAPC::EU 2014, Bulgaria, Keynote
Disappearing Managers, YAPC::EU 2014, Bulgaria, KeynoteDisappearing Managers, YAPC::EU 2014, Bulgaria, Keynote
Disappearing Managers, YAPC::EU 2014, Bulgaria, KeynoteCurtis Poe
 
How to Fake a Database Design
How to Fake a Database DesignHow to Fake a Database Design
How to Fake a Database DesignCurtis Poe
 
Are Managers An Endangered Species?
Are Managers An Endangered Species?Are Managers An Endangered Species?
Are Managers An Endangered Species?Curtis Poe
 
The Lies We Tell About Software Testing
The Lies We Tell About Software TestingThe Lies We Tell About Software Testing
The Lies We Tell About Software TestingCurtis Poe
 
A/B Testing - What your mother didn't tell you
A/B Testing - What your mother didn't tell youA/B Testing - What your mother didn't tell you
A/B Testing - What your mother didn't tell youCurtis Poe
 
Test::Class::Moose
Test::Class::MooseTest::Class::Moose
Test::Class::MooseCurtis Poe
 
A Whirlwind Tour of Test::Class
A Whirlwind Tour of Test::ClassA Whirlwind Tour of Test::Class
A Whirlwind Tour of Test::ClassCurtis Poe
 
Agile Companies Go P.O.P.
Agile Companies Go P.O.P.Agile Companies Go P.O.P.
Agile Companies Go P.O.P.Curtis Poe
 
Testing With Test::Class
Testing With Test::ClassTesting With Test::Class
Testing With Test::ClassCurtis Poe
 
Logic Progamming in Perl
Logic Progamming in PerlLogic Progamming in Perl
Logic Progamming in PerlCurtis Poe
 
Inheritance Versus Roles - The In-Depth Version
Inheritance Versus Roles - The In-Depth VersionInheritance Versus Roles - The In-Depth Version
Inheritance Versus Roles - The In-Depth VersionCurtis Poe
 
Inheritance Versus Roles
Inheritance Versus RolesInheritance Versus Roles
Inheritance Versus RolesCurtis Poe
 

More from Curtis Poe (20)

How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
life-off-earth.pptx
life-off-earth.pptxlife-off-earth.pptx
life-off-earth.pptx
 
Corinna-2023.pptx
Corinna-2023.pptxCorinna-2023.pptx
Corinna-2023.pptx
 
Corinna Status 2022.pptx
Corinna Status 2022.pptxCorinna Status 2022.pptx
Corinna Status 2022.pptx
 
Rummaging in the clOOset
Rummaging in the clOOsetRummaging in the clOOset
Rummaging in the clOOset
 
Rescuing a-legacy-codebase
Rescuing a-legacy-codebaseRescuing a-legacy-codebase
Rescuing a-legacy-codebase
 
Perl 6 For Mere Mortals
Perl 6 For Mere MortalsPerl 6 For Mere Mortals
Perl 6 For Mere Mortals
 
Disappearing Managers, YAPC::EU 2014, Bulgaria, Keynote
Disappearing Managers, YAPC::EU 2014, Bulgaria, KeynoteDisappearing Managers, YAPC::EU 2014, Bulgaria, Keynote
Disappearing Managers, YAPC::EU 2014, Bulgaria, Keynote
 
How to Fake a Database Design
How to Fake a Database DesignHow to Fake a Database Design
How to Fake a Database Design
 
Are Managers An Endangered Species?
Are Managers An Endangered Species?Are Managers An Endangered Species?
Are Managers An Endangered Species?
 
The Lies We Tell About Software Testing
The Lies We Tell About Software TestingThe Lies We Tell About Software Testing
The Lies We Tell About Software Testing
 
A/B Testing - What your mother didn't tell you
A/B Testing - What your mother didn't tell youA/B Testing - What your mother didn't tell you
A/B Testing - What your mother didn't tell you
 
Test::Class::Moose
Test::Class::MooseTest::Class::Moose
Test::Class::Moose
 
A Whirlwind Tour of Test::Class
A Whirlwind Tour of Test::ClassA Whirlwind Tour of Test::Class
A Whirlwind Tour of Test::Class
 
Agile Companies Go P.O.P.
Agile Companies Go P.O.P.Agile Companies Go P.O.P.
Agile Companies Go P.O.P.
 
Econ101
Econ101Econ101
Econ101
 
Testing With Test::Class
Testing With Test::ClassTesting With Test::Class
Testing With Test::Class
 
Logic Progamming in Perl
Logic Progamming in PerlLogic Progamming in Perl
Logic Progamming in Perl
 
Inheritance Versus Roles - The In-Depth Version
Inheritance Versus Roles - The In-Depth VersionInheritance Versus Roles - The In-Depth Version
Inheritance Versus Roles - The In-Depth Version
 
Inheritance Versus Roles
Inheritance Versus RolesInheritance Versus Roles
Inheritance Versus Roles
 

Recently uploaded

SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Hyundai Motor Group
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 

Recently uploaded (20)

SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 

Turbo Charged Test Suites

  • 1. Turbo Charged Test Suites Tuesday, 7 October 2008
  • 2. Curtis “Ovid” Poe • CPAN Author • “Perl Hacks” Contributor • Perl Foundation Member Tuesday, 7 October 2008
  • 3. Test Suite Performance • Computer • Developer Tuesday, 7 October 2008
  • 4. Faster Tests Tuesday, 7 October 2008
  • 5. Considerations • Why speed things up? • Trade-offs Tuesday, 7 October 2008
  • 6. Before You Start • Set a goal • No tests may fail • No non-test output Tuesday, 7 October 2008
  • 7. Databases • Don’t drop them • Don’t fake it with transactions Tuesday, 7 October 2008
  • 8. Databases • Static tables -- country_codes • Dynamic tables -- orders Tuesday, 7 October 2008
  • 9. CREATE TABLE changed_table ( changed_table_id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, table_name VARCHAR(30) NOT NULL, is_static INT NOT NULL DEFAULT 0, inserts INT NOT NULL DEFAULT 0, updates INT NOT NULL DEFAULT 0, deletes INT NOT NULL DEFAULT 0 ) -- then insert table records Tuesday, 7 October 2008
  • 10. foreach my $action (qw/insert update delete/) { $dbh->do(<<quot; END_SQLquot;); CREATE TRIGGER tr_${action}_$table BEFORE $action ON $table FOR EACH ROW UPDATE changed_table SET ${action}s = ${action}s + 1 WHERE table_name = '$table'; END_SQL } Tuesday, 7 October 2008
  • 11. db.disable_foreign_keys() for table in changed_tables() table.truncate() if table.is_static() table.rebuild() db.enable_foreign_keys() Tuesday, 7 October 2008
  • 12. Databases • Before: 80 minutes • After: 22 minutes Tuesday, 7 October 2008
  • 13. Aggregation • Only load things once • Dangers of shared state Tuesday, 7 October 2008
  • 14. use My::YAML::Test; My::YAML::Test->run; # t/api/customer.t # t/api/customer.yml Tuesday, 7 October 2008
  • 15. use My::YAML::Test; foreach (yaml_tests()) { diag “running $_”; My::YAML::Test->run($_); } sub yaml_tests { return @ARGV if @ARGV; # or return all YAML files ... } Tuesday, 7 October 2008
  • 16. YAML Aggregation • Before: 22 minutes • After: 16 minutes Tuesday, 7 October 2008
  • 17. use Test::Aggregate; my $tests = Test::Aggregate->new({ dirs => ‘aggtests’, }); $tests->run; Tuesday, 7 October 2008
  • 18. use Test::Aggregate; my $tests = Test::Aggregate->new({ dirs => 'aggtests', dump => $dump, set_filenames => 1, shuffle => 1, startup => &startup, shutdown => &shutdown, }); Tuesday, 7 October 2008
  • 19. Generic Aggregation • Before: 16 minutes • After: 12 minutes Tuesday, 7 October 2008
  • 20. Better Aggregation • use Test::Class Tuesday, 7 October 2008
  • 21. OK to Fail is OK • POD tests • Perl::Critic • Anything “non-functional” Tuesday, 7 October 2008
  • 22. OK to Fail is OK • Move them to xt/ • But they must be run! Tuesday, 7 October 2008
  • 23. Lessons Learned • Not dropping your database is tricky • Aggregating tests finds bugs in tests • Aggregating tests finds bugs in code • *CORE::GLOBAL:: is evil • Don’t touch UNIVERSAL:: Tuesday, 7 October 2008
  • 26. use Test::More tests => 13; use Test::Exception; use Test::XML; use Test::JSON; use Test::Differences; Tuesday, 7 October 2008
  • 27. package Our::Test::More; use Test::Builder::Module; our ( @ISA, @EXPORT ); use Test::More; use Test::Exception; BEGIN { @ISA = qw(Test::Builder::Module); @EXPORT = ( @Test::More::EXPORT, @Test::Exception::EXPORT, ); } 1; Tuesday, 7 October 2008
  • 28. package My::Custom::Tests; use Test::Kit ( 'Test::More', 'Test::XML', 'Test::Differences', '+explain', ); 1; Tuesday, 7 October 2008
  • 29. Popularity Contest Test::More 44461 Test 8937 Test::Exception 1397 Test::Simple 731 Test::Base 316 Test::Builder::Tester 193 Test::NoWarnings 174 Test::Differences 146 Test::MockObject 139 Test::Deep 127 Tuesday, 7 October 2008
  • 30. use Test::Most tests => 4, 'die'; ok 1, 'one is true'; is 2, 2, '... and two is two'; eq_or_diff [3], [4], “... but three ain’t four”; throws_ok { $foo/0 } qr/Illegal division by zero/, 'and no-constant folding with vars'; Tuesday, 7 October 2008
  • 31. Test From Your Editor Tuesday, 7 October 2008
  • 32. “ in your .vimrc function! PerlMappings() noremap K :!perldoc <cword> <bar><bar> perldoc -f <cword><cr> endfunction function! PerlTestMappings() noremap <buffer> ,t :!prove -vl %<CR> endfunction “ remember My::Test::YAML? function! YAMLTestMappings() noremap <buffer> ,t :!prove -vl t/yaml.t :: %<CR> endfunction au! FileType perl :call PerlMappings() au! FileType yaml :call YAMLTestMappings() au! BufRead,BufNewFile *.t :call PerlTestMappings() Tuesday, 7 October 2008
  • 33. vim $(ack -l --perl 'api/v1/episode' t/) map <leader>tb :call RunTestsInBuffers()<cr> function! RunTestsInBuffers() let i = 1 let tests = '' while (i <= bufnr(quot;$quot;)) let filename = bufname(i) if match(filename, '.t$') > -1 let tests = tests . ' quot;' . filename . 'quot;' endif let i = i+1 endwhile if !strlen(tests) echo quot;No tests found in buffersquot; else execute ':!prove ' . tests endif endfunction Tuesday, 7 October 2008
  • 35. Test-Harness $ prove -l t --state=hot,fast,save --timer [20:57:19] t/yamlish-output.........ok 40 ms [20:57:20] t/console................ok 45 ms [20:57:20] t/utils..................ok 48 ms <snip> [20:57:23] t/harness................ok 300 ms [20:57:23] t/process................ok 1020 ms [20:57:24] t/prove..................ok 1017 ms [20:57:25] t/regression.............ok 4217 ms [20:57:29] All tests successful. Files=32, Tests=10326, 10 wallclock secs ( 1.25 usr 0.24 sys + 5.60 cusr 1.83 csys = 8.92 CPU) Result: PASS Tuesday, 7 October 2008
  • 36. Test-Harness $ prove -l t --state=hot,slow,save -j 9 t/callbacks.............. ok t/nofork................. ok t/proverc................ ok <snip> t/yamlish................ ok t/prove.................. ok t/regression............. ok All tests successful. Files=32, Tests=10326, 6 wallclock secs ( 1.34 usr 0.24 sys + 5.63 cusr 1.83 csys = 9.04 CPU) Result: PASS Tuesday, 7 October 2008
  • 37. # slow running tests from App::Prove::State # http://use.perl.org/~Ovid/journal/35831 Generation 18 Number of test programs: 58 Total runtime approximately 17 minutes 35 seconds Five slowest tests: 482.7 seconds -> t/acceptance.t 234.4 seconds -> t/aggregate.t 96.3 seconds -> t/standards/strict.t 66.6 seconds -> t/unit/db/migrations.t 56.7 seconds -> t/unit/piptest/pprove/testdb.t Tuesday, 7 October 2008
  • 39. Devel::CoverX::Covered • What tests cover this file? • What files are covered by this test? • (Soon) What tests cover this line? • (Soon) What tests cover this subroutine? • ... and more ... Tuesday, 7 October 2008
  • 40. function! PerlMappings() noremap <buffer> ,cv :call Coverage()<cr> endfunction function! PerlTestMappings() noremap <buffer> ,t :!prove -vl --norc %<CR> endfunction function! Coverage() let file = bufname('%') if match(filename, '.t$') > -1 execute '!covered by --test_file=quot;'.file.'quot;' else execute '!covered covering --source_file=quot;'.file.'quot;' end endfunction au! FileType perl :call PerlMappings() au! BufRead,BufNewFile *.t :call PerlTestMappings() Tuesday, 7 October 2008