SlideShare una empresa de Scribd logo
1 de 15
Real Life Cross-Platform Testing
Peter Edwards
peter@dragonstaff.co.uk


MiltonKeynes.pm
Perl Technical Talk
8th July 2008




                                               1
      Real Life Cross-Platform Testing   12/22/12
Contents
 Background aka      "Real Life"
 Cross-Platform
 Testing

 Add Windows Testing Under Unix
 Test::MockObject
 Test::MockModule
 Running Unix unit tests under Windows
 Future Plans For Testing
 Summary and Links



                                                  2
Real Life Cross-Platform Testing          12/22/12
Background aka "Real Life"
Content Management System used at BBC to enter XML documents
  that are later transformed to make public websites
   Client-side
     –   GUI using WxPerl (WxWidgets)
     –   WYSIWYG editing
     –   Talks SOAP over HTTP to server
     –   Runs under ActiveState Perl
   Server-side
     –   Handles SOAP requests
     –   Stores document blobs in filesystem
     –   Stores indexes, metadata in Oracle database
     –   Runs under Solaris Perl
   Usage
     – 100s of users
     – Time critical publishing : failure during release is not an option
                                                                               3
Real Life Cross-Platform Testing                                       12/22/12
Cross-Platform
CMS code running on Windows and Solaris
   Solaris perl 5.8.8
     $ perl -V
     Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
      Platform:
        osname=solaris, osvers=2.10, archname=sun4-solaris

   Windows ASPerl 5.8
     C:WINNT>perl –V
     Summary of my perl5 (revision 5 version 8 subversion 6) configuration:
      Platform:
       osname=MSWin32, osvers=4.0, archname=MSWin32-x86-multi-thread


                                                                           4
Real Life Cross-Platform Testing                                   12/22/12
Testing
 Unit tests for dev
 Automated overnight smoke testing of unit tests
 Dev / Staging Test / Live environments
 Manual release test on staging test area using
  Windows app
Problems
 Lots of tests for server side code, very few for
  client side because difficult to run 'use Wx' code
  on Unix in batch
 Existing tests run on Unix, fail on Windows


                                                      5
Real Life Cross-Platform Testing              12/22/12
Add Windows Testing Under Unix
Need to write lots of client-side tests for
1)   GUI
       WxPerl -> Gtk+ under Solaris
         ‘Use Wx’ was failing because no X display
         Problems with font sizing and window alignment
         Windows-specific components, e.g. ActiveX Altova editor
     Installation
         Shortcuts, registry Win32::OLE, unzipping archives to Windows Apps dir etc.
Solutions
1)    Use Xvfb
         $ alias runxvfb='Xvfb :10 -dev vfb screen 0 1152x900x8 > /dev/null 2>&1 &'
         Lets you check code compile and call many routines
         But how do you test UI rendered properly - interpreting the virtual screen
               bitmaps is too hard!
1)    Sandboxing and mocking
         Mock required Win32 functions
         Make them do file I/O to a sandbox area
         Test::MockObject - Perl extension for emulating troublesome interfaces
         Test::MockModule - Override subroutines in a module for unit testing
                                                                                   6
Real Life Cross-Platform Testing                                           12/22/12
Test::MockObject 1
     Helpers

    sub make_mock_obj_in_class {
      my $class = shift;
      my $obj = Test::MockObject->new;
      $obj->fake_module($class);
      $obj->fake_new($class);
      return $obj;
    }

    sub dump_mock_calls {
      my $mockobj = shift;
      my $i = 1;
      while ( my $name = $mockobj->call_pos($i) ) {
         diag " call $i: $name";
         my @args = $mockobj->call_args($i);
         for (0 .. $#args) {
            diag ' arg '.($_ +1).': ';
            diag Dumper($args[$_]);
         }
         $i++;
      }
    }




                                                              7
Real Life Cross-Platform Testing                      12/22/12
Test::MockObject 2
      Mocking

    my $wx = make_mock_obj_in_class( 'Wx' );

    my $mock_WxPerlSplashProgress = make_mock_obj_in_class( 'Wx::Perl::SplashProgress' );
    $mock_WxPerlSplashProgress->set_true(qw( SetLabelColour SetIcon Show SetValue Update Destroy ));
    $mock_WxPerlSplashProgress->mock( SetLabel => sub { diag ' SetLabel: '.$_[1] } );

    $mock_Win32OLE = make_mock_obj_in_class( 'Win32::OLE' );
    $mock_Win32OLE->mock( 'SpecialFolders', sub { shift } );
    $mock_Win32OLE->mock( 'AppData', sub { return catdir(qw(data win32), 'Application Data') } );
    $mock_Win32OLE->mock( 'StartMenu', sub { catdir(qw(data win32 startmenu)) } );
    $mock_Win32OLE->mock( 'Desktop', sub { catdir(qw(data win32 desktop)) } );

    $mock_Win32Shortcut = make_mock_obj_in_class( 'Win32::Shortcut' );
    $mock_Win32Shortcut->mock( 'Load', sub {
       my ($self, $filename) = @_;
       $self->{content} = read_file($filename);
       return 1;
       } );
    $mock_Win32Shortcut->mock( 'Path', sub {
       my ($self, $path) = @_;
       $self->{content} = $path;
       } );
    $mock_Win32Shortcut->mock( 'Arguments', sub {
       my ($self, $args) = @_;
       $self->{content} .= ' '.$args . "rn";
       } );
    $mock_Win32Shortcut->mock( 'Save', sub {
       my ($self, $filename) = @_;
       write_file($filename, $self->{content} . "writetime ". gmtime() . "rn");
       return 1;
       } );
    $mock_Win32Shortcut->set_true(qw( ShowCmd Description IconLocation Close ));
    { no strict 'refs'; *{'Win32::Shortcut::SW_SHOWMINNOACTIVE'} = sub {}; }



                                                                                                               8
Real Life Cross-Platform Testing                                                                       12/22/12
Test::MockObject 3
   Testing
$mock_WxPerlSplashProgress->clear();
is( $i->_install_loginscript, 1, '$i->_install_loginscript' );
dump_mock_calls($mock_IFLDesktopLoginScript);
$mock_IFLDesktopLoginScript->called_pos_ok( 3, 'install', 'called
    IFL::Desktop::LoginScript->install' );
dump_mock_calls($mock_WxPerlSplashProgress);
$mock_WxPerlSplashProgress->called_pos_ok( 4, 'SetLabel', 'called
    Wx::Perl::SplashProgress->SetLabel' );
$mock_WxPerlSplashProgress->called_args_pos_is( 4, 2, 'Checking
    login script' );
$mock_WxPerlSplashProgress->called_pos_ok( 7, 'SetLabel', 'called
    Wx::Perl::SplashProgress->SetLabel' );
$mock_WxPerlSplashProgress->called_args_pos_is( 7, 2, 'Installing
    login script...' );



                                                                   9
Real Life Cross-Platform Testing                           12/22/12
Test::MockModule 1
   Helper
sub mock_module {
    my ($module,$options,@functions) = @_;

    my $no_auto = defined($options->{no_auto}) ? $options->{no_auto} : 1;
    my $create_new = defined($options->{create_new}) ? $options->{create_new} : 1;
    my $testmockmodule = new Test::MockModule($module, no_auto => $no_auto);

    my $object;
    if ($create_new) {
       $object = bless {}, $module;
       $testmockmodule->mock('new',sub { $logger->log($module,'new',@_); return $object });
    }

    for my $function (@functions) {
       $testmockmodule->mock($function,sub { $logger->log($module,$function,@_) });
    }

    no strict 'refs';
    push @{$module . "::ISA"},'Exporter';

    my $module_path = $module;
    $module_path =~ s{::}{/}xmsg;
    $module_path .= '.pm';
    $INC{$module_path} = "1 (Inserted by mock_module())";

    return $testmockmodule, $object;
}

                                                                                                     10
Real Life Cross-Platform Testing                                                              12/22/12
Test::MockModule 2
   Mocking
     my ($mock_wx_activex_ie, $mock_wx_activex_ie_object)
         = mock_module('Wx::ActiveX::IE',{});
     my ($mock_wx_activex_event, $mock_wx_activex_event_object)
         = mock_module('Wx::ActiveX::Event',{},@Wx::Event::EXPORT_OK);
     my ($mock_wx_panel,$mock_wx_panel_object)
         = mock_module('Wx::Panel',{}, qw( SetSizer ));
     my ($mock_wx_boxsizer,$mock_wx_boxsizer_object)
         = mock_module('Wx::BoxSizer',{}, qw( Add ));

   Tests - use your objects as normal… then check call sequence
     my @mf_calls = $logger->filter({'FLIPClient::UI::MicroForms' => []});
     my $call = shift(@mf_calls);
     is($call->{function},'set_template','position_change (' . $test->{name} . ') calls set_template');
     ok($call->{args}->[1] =~ $test->{template},'position_change (' . $test->{name} . ') sets
         template');

     $call = shift(@mf_calls);
     is($call->{function},'set_data','position_change (' . $test->{name} . ') calls set_data');
     is_deeply($call->{args}->[1],$test->{data},'position_change (' . $test->{name} . ') sets data');




                                                                                                   11
Real Life Cross-Platform Testing                                                            12/22/12
Running Unix unit tests under Windows 1

   Some libraries shared between Unix and Windows;
    not being tested properly client-side
   Perl Portability
    – "perldoc perlport“ http://perldoc.perl.org/5.8.8/perlport.html
      "When the code will run on only two or three operating systems,
      you may need to consider only the differences of those particular
      systems. The important thing is to decide where the code will run
      and to be deliberate in your decision.“
    – Only worrying about Windows and Unix; OpenVMS support is
      hard
           binmode and chomp - binmode saves headaches on Windows like
            EOF ^Z; watch out for CR-LF
           use File::Spec::Functions rather than Unix paths
              YES : my $path = rel2abs( catdir(qw( data local cache file.txt ));
              NO : my $path = './data/local/cache/file.txt';

                                                                                    12
Real Life Cross-Platform Testing                                             12/22/12
Running Unix unit tests under Windows 2
   Generic configuration interface with platform-specific subclasses
          System.pm
               |-- System/Win32.pm
               |-- System/Unix.pm
          using File::Spec::Functions for paths
   Change tests from path strings to regexes using a quote path
    separator
           my $script = $i->startup('remote');
     NO : is( $script, 'scripts/FLIP_real.PL', '$i->startup("remote") script’
     YES : $ps = ($^O eq 'MSWin32') ? "" : '/';
           $qps = quotemeta $ps;
           like( $script, qr{ scripts [$qps] FLIP_real.pl z }xms, '$i-
       >startup("remote") script' );
     Note PBP style regex
   Actually run the tests on multiple platforms


                                                                               13
Real Life Cross-Platform Testing                                        12/22/12
Future Plans For Testing
 Automate      application release test under
   Windows
    – Win32::GuiTest (or pay for WinRunner)




                                                  14
Real Life Cross-Platform Testing           12/22/12
Summary and Links
   Summary
    –   "perldoc perlport“
    –   Write cross-platform tests from the outset; convert old ones
    –   Mock platform-specific GUI or system library calls
    –   Automate tests (life is short) and get as much coverage as
        possible

   Links
    – WxPerl http://wxperl.sourceforge.net/
    – WxWidgets http://docs.wxwidgets.org/trunk/
    – "Perl Testing: A Developer's Notebook" Ian Langworth &
      chromatic, O'Reilly Media, Inc., 2005
      http://preview.tinyurl.com/5k6wnc

Thank you. Any Questions?

                                                                       15
Real Life Cross-Platform Testing                                12/22/12

Más contenido relacionado

La actualidad más candente

Custom deployments with sbt-native-packager
Custom deployments with sbt-native-packagerCustom deployments with sbt-native-packager
Custom deployments with sbt-native-packagerGaryCoady
 
Design Patterns Reconsidered
Design Patterns ReconsideredDesign Patterns Reconsidered
Design Patterns ReconsideredAlex Miller
 
Dependency Injection in PHP
Dependency Injection in PHPDependency Injection in PHP
Dependency Injection in PHPKacper Gunia
 
GeeCON 2017 - TestContainers. Integration testing without the hassle
GeeCON 2017 - TestContainers. Integration testing without the hassleGeeCON 2017 - TestContainers. Integration testing without the hassle
GeeCON 2017 - TestContainers. Integration testing without the hassleAnton Arhipov
 
Exercícios Netbeans - Vera Cymbron
Exercícios Netbeans - Vera CymbronExercícios Netbeans - Vera Cymbron
Exercícios Netbeans - Vera Cymbroncymbron
 
«Objective-C Runtime в примерах» — Алексей Сторожев, e-Legion
«Objective-C Runtime в примерах» — Алексей Сторожев, e-Legion«Objective-C Runtime в примерах» — Алексей Сторожев, e-Legion
«Objective-C Runtime в примерах» — Алексей Сторожев, e-Legione-Legion
 
Rails-like JavaScript Using CoffeeScript, Backbone.js and Jasmine
Rails-like JavaScript Using CoffeeScript, Backbone.js and JasmineRails-like JavaScript Using CoffeeScript, Backbone.js and Jasmine
Rails-like JavaScript Using CoffeeScript, Backbone.js and JasmineRaimonds Simanovskis
 
Clojure - A new Lisp
Clojure - A new LispClojure - A new Lisp
Clojure - A new Lispelliando dias
 
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
 
Building stable testing by isolating network layer
Building stable testing by isolating network layerBuilding stable testing by isolating network layer
Building stable testing by isolating network layerJz Chang
 
Mastering Java Bytecode With ASM - 33rd degree, 2012
Mastering Java Bytecode With ASM - 33rd degree, 2012Mastering Java Bytecode With ASM - 33rd degree, 2012
Mastering Java Bytecode With ASM - 33rd degree, 2012Anton Arhipov
 
Java Bytecode for Discriminating Developers - JavaZone 2011
Java Bytecode for Discriminating Developers - JavaZone 2011Java Bytecode for Discriminating Developers - JavaZone 2011
Java Bytecode for Discriminating Developers - JavaZone 2011Anton Arhipov
 
Android Unit Test
Android Unit TestAndroid Unit Test
Android Unit TestPhuoc Bui
 

La actualidad más candente (20)

Custom deployments with sbt-native-packager
Custom deployments with sbt-native-packagerCustom deployments with sbt-native-packager
Custom deployments with sbt-native-packager
 
Java script for web developer
Java script for web developerJava script for web developer
Java script for web developer
 
droidparts
droidpartsdroidparts
droidparts
 
Design Patterns Reconsidered
Design Patterns ReconsideredDesign Patterns Reconsidered
Design Patterns Reconsidered
 
Dependency Injection in PHP
Dependency Injection in PHPDependency Injection in PHP
Dependency Injection in PHP
 
GeeCON 2017 - TestContainers. Integration testing without the hassle
GeeCON 2017 - TestContainers. Integration testing without the hassleGeeCON 2017 - TestContainers. Integration testing without the hassle
GeeCON 2017 - TestContainers. Integration testing without the hassle
 
Testing with Node.js
Testing with Node.jsTesting with Node.js
Testing with Node.js
 
Exercícios Netbeans - Vera Cymbron
Exercícios Netbeans - Vera CymbronExercícios Netbeans - Vera Cymbron
Exercícios Netbeans - Vera Cymbron
 
«Objective-C Runtime в примерах» — Алексей Сторожев, e-Legion
«Objective-C Runtime в примерах» — Алексей Сторожев, e-Legion«Objective-C Runtime в примерах» — Алексей Сторожев, e-Legion
«Objective-C Runtime в примерах» — Алексей Сторожев, e-Legion
 
Mastering Java ByteCode
Mastering Java ByteCodeMastering Java ByteCode
Mastering Java ByteCode
 
Rails-like JavaScript Using CoffeeScript, Backbone.js and Jasmine
Rails-like JavaScript Using CoffeeScript, Backbone.js and JasmineRails-like JavaScript Using CoffeeScript, Backbone.js and Jasmine
Rails-like JavaScript Using CoffeeScript, Backbone.js and Jasmine
 
Clojure - A new Lisp
Clojure - A new LispClojure - A new Lisp
Clojure - A new Lisp
 
meet.js - QooXDoo
meet.js - QooXDoomeet.js - QooXDoo
meet.js - QooXDoo
 
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
 
Building stable testing by isolating network layer
Building stable testing by isolating network layerBuilding stable testing by isolating network layer
Building stable testing by isolating network layer
 
Modern c++
Modern c++Modern c++
Modern c++
 
#JavaFX.forReal() - ElsassJUG
#JavaFX.forReal() - ElsassJUG#JavaFX.forReal() - ElsassJUG
#JavaFX.forReal() - ElsassJUG
 
Mastering Java Bytecode With ASM - 33rd degree, 2012
Mastering Java Bytecode With ASM - 33rd degree, 2012Mastering Java Bytecode With ASM - 33rd degree, 2012
Mastering Java Bytecode With ASM - 33rd degree, 2012
 
Java Bytecode for Discriminating Developers - JavaZone 2011
Java Bytecode for Discriminating Developers - JavaZone 2011Java Bytecode for Discriminating Developers - JavaZone 2011
Java Bytecode for Discriminating Developers - JavaZone 2011
 
Android Unit Test
Android Unit TestAndroid Unit Test
Android Unit Test
 

Destacado

Installation instructions p8p bb bridge
Installation instructions   p8p bb bridgeInstallation instructions   p8p bb bridge
Installation instructions p8p bb bridgeYuri Grin
 
экслибрис текст
экслибрис текстэкслибрис текст
экслибрис текстYuri Grin
 
World contemporary screen
World contemporary screenWorld contemporary screen
World contemporary screenYuri Grin
 
Sbrf on-line manual
Sbrf on-line manualSbrf on-line manual
Sbrf on-line manualYuri Grin
 
экслибрис иллюстрации
экслибрис иллюстрацииэкслибрис иллюстрации
экслибрис иллюстрацииYuri Grin
 
BBC World Service Twitter OAuth Perl
BBC World Service Twitter OAuth PerlBBC World Service Twitter OAuth Perl
BBC World Service Twitter OAuth PerlPeter Edwards
 
Rti implementation
Rti implementationRti implementation
Rti implementationmmcarl0928
 
дневники суточного мониторирования
дневники суточного мониторированиядневники суточного мониторирования
дневники суточного мониторированияYuri Grin
 

Destacado (9)

Installation instructions p8p bb bridge
Installation instructions   p8p bb bridgeInstallation instructions   p8p bb bridge
Installation instructions p8p bb bridge
 
экслибрис текст
экслибрис текстэкслибрис текст
экслибрис текст
 
World contemporary screen
World contemporary screenWorld contemporary screen
World contemporary screen
 
Sbrf on-line manual
Sbrf on-line manualSbrf on-line manual
Sbrf on-line manual
 
экслибрис иллюстрации
экслибрис иллюстрацииэкслибрис иллюстрации
экслибрис иллюстрации
 
BBC World Service Twitter OAuth Perl
BBC World Service Twitter OAuth PerlBBC World Service Twitter OAuth Perl
BBC World Service Twitter OAuth Perl
 
Rti implementation
Rti implementationRti implementation
Rti implementation
 
дневники суточного мониторирования
дневники суточного мониторированиядневники суточного мониторирования
дневники суточного мониторирования
 
Lotoshino
LotoshinoLotoshino
Lotoshino
 

Similar a Real world cross-platform testing

Harmonious Development: Via Vagrant and Puppet
Harmonious Development: Via Vagrant and PuppetHarmonious Development: Via Vagrant and Puppet
Harmonious Development: Via Vagrant and PuppetAchieve Internet
 
Integration tests: use the containers, Luke!
Integration tests: use the containers, Luke!Integration tests: use the containers, Luke!
Integration tests: use the containers, Luke!Roberto Franchini
 
HTML5 for the Silverlight Guy
HTML5 for the Silverlight GuyHTML5 for the Silverlight Guy
HTML5 for the Silverlight GuyDavid Padbury
 
Automation with Ansible and Containers
Automation with Ansible and ContainersAutomation with Ansible and Containers
Automation with Ansible and ContainersRodolfo Carvalho
 
Burn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesBurn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesLindsay Holmwood
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing UpDavid Padbury
 
Infrastructure-as-code: bridging the gap between Devs and Ops
Infrastructure-as-code: bridging the gap between Devs and OpsInfrastructure-as-code: bridging the gap between Devs and Ops
Infrastructure-as-code: bridging the gap between Devs and OpsMykyta Protsenko
 
Cool JVM Tools to Help You Test
Cool JVM Tools to Help You TestCool JVM Tools to Help You Test
Cool JVM Tools to Help You TestSchalk Cronjé
 
Tools and Tips for Moodle Developers - #mootus16
 Tools and Tips for Moodle Developers - #mootus16 Tools and Tips for Moodle Developers - #mootus16
Tools and Tips for Moodle Developers - #mootus16Dan Poltawski
 
soft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch
 
Live deployment, ci, drupal
Live deployment, ci, drupalLive deployment, ci, drupal
Live deployment, ci, drupalAndrii Podanenko
 
Symfony2 - from the trenches
Symfony2 - from the trenchesSymfony2 - from the trenches
Symfony2 - from the trenchesLukas Smith
 
Building Testable PHP Applications
Building Testable PHP ApplicationsBuilding Testable PHP Applications
Building Testable PHP Applicationschartjes
 
Singletons in PHP - Why they are bad and how you can eliminate them from your...
Singletons in PHP - Why they are bad and how you can eliminate them from your...Singletons in PHP - Why they are bad and how you can eliminate them from your...
Singletons in PHP - Why they are bad and how you can eliminate them from your...go_oh
 
Browser testing with nightwatch.js - Drupal Europe
Browser testing with nightwatch.js - Drupal EuropeBrowser testing with nightwatch.js - Drupal Europe
Browser testing with nightwatch.js - Drupal EuropeSalvador Molina (Slv_)
 

Similar a Real world cross-platform testing (20)

Agile Swift
Agile SwiftAgile Swift
Agile Swift
 
Harmonious Development: Via Vagrant and Puppet
Harmonious Development: Via Vagrant and PuppetHarmonious Development: Via Vagrant and Puppet
Harmonious Development: Via Vagrant and Puppet
 
Integration tests: use the containers, Luke!
Integration tests: use the containers, Luke!Integration tests: use the containers, Luke!
Integration tests: use the containers, Luke!
 
lecture5
lecture5lecture5
lecture5
 
lecture5
lecture5lecture5
lecture5
 
HTML5 for the Silverlight Guy
HTML5 for the Silverlight GuyHTML5 for the Silverlight Guy
HTML5 for the Silverlight Guy
 
Automation with Ansible and Containers
Automation with Ansible and ContainersAutomation with Ansible and Containers
Automation with Ansible and Containers
 
Burn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesBurn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websites
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
 
Infrastructure-as-code: bridging the gap between Devs and Ops
Infrastructure-as-code: bridging the gap between Devs and OpsInfrastructure-as-code: bridging the gap between Devs and Ops
Infrastructure-as-code: bridging the gap between Devs and Ops
 
Cool JVM Tools to Help You Test
Cool JVM Tools to Help You TestCool JVM Tools to Help You Test
Cool JVM Tools to Help You Test
 
Tools and Tips for Moodle Developers - #mootus16
 Tools and Tips for Moodle Developers - #mootus16 Tools and Tips for Moodle Developers - #mootus16
Tools and Tips for Moodle Developers - #mootus16
 
Nodejs Intro Part One
Nodejs Intro Part OneNodejs Intro Part One
Nodejs Intro Part One
 
soft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.js
 
Live deployment, ci, drupal
Live deployment, ci, drupalLive deployment, ci, drupal
Live deployment, ci, drupal
 
Symfony2 - from the trenches
Symfony2 - from the trenchesSymfony2 - from the trenches
Symfony2 - from the trenches
 
Fatc
FatcFatc
Fatc
 
Building Testable PHP Applications
Building Testable PHP ApplicationsBuilding Testable PHP Applications
Building Testable PHP Applications
 
Singletons in PHP - Why they are bad and how you can eliminate them from your...
Singletons in PHP - Why they are bad and how you can eliminate them from your...Singletons in PHP - Why they are bad and how you can eliminate them from your...
Singletons in PHP - Why they are bad and how you can eliminate them from your...
 
Browser testing with nightwatch.js - Drupal Europe
Browser testing with nightwatch.js - Drupal EuropeBrowser testing with nightwatch.js - Drupal Europe
Browser testing with nightwatch.js - Drupal Europe
 

Más de Peter Edwards

Enhancing engagement through content
Enhancing engagement through contentEnhancing engagement through content
Enhancing engagement through contentPeter Edwards
 
Perl exceptions lightning talk
Perl exceptions lightning talkPerl exceptions lightning talk
Perl exceptions lightning talkPeter Edwards
 
Role based access control
Role based access controlRole based access control
Role based access controlPeter Edwards
 
Getting started with Catalyst and extjs
Getting started with Catalyst and extjsGetting started with Catalyst and extjs
Getting started with Catalyst and extjsPeter Edwards
 
Desperately seeking a lightweight Perl framework
Desperately seeking a lightweight Perl frameworkDesperately seeking a lightweight Perl framework
Desperately seeking a lightweight Perl frameworkPeter Edwards
 
Open Source for Government - PSEICT Conference - British Council Case Study u...
Open Source for Government - PSEICT Conference - British Council Case Study u...Open Source for Government - PSEICT Conference - British Council Case Study u...
Open Source for Government - PSEICT Conference - British Council Case Study u...Peter Edwards
 

Más de Peter Edwards (7)

Enhancing engagement through content
Enhancing engagement through contentEnhancing engagement through content
Enhancing engagement through content
 
Twitter oauth
Twitter oauthTwitter oauth
Twitter oauth
 
Perl exceptions lightning talk
Perl exceptions lightning talkPerl exceptions lightning talk
Perl exceptions lightning talk
 
Role based access control
Role based access controlRole based access control
Role based access control
 
Getting started with Catalyst and extjs
Getting started with Catalyst and extjsGetting started with Catalyst and extjs
Getting started with Catalyst and extjs
 
Desperately seeking a lightweight Perl framework
Desperately seeking a lightweight Perl frameworkDesperately seeking a lightweight Perl framework
Desperately seeking a lightweight Perl framework
 
Open Source for Government - PSEICT Conference - British Council Case Study u...
Open Source for Government - PSEICT Conference - British Council Case Study u...Open Source for Government - PSEICT Conference - British Council Case Study u...
Open Source for Government - PSEICT Conference - British Council Case Study u...
 

Último

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
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
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 

Último (20)

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
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
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 

Real world cross-platform testing

  • 1. Real Life Cross-Platform Testing Peter Edwards peter@dragonstaff.co.uk MiltonKeynes.pm Perl Technical Talk 8th July 2008 1 Real Life Cross-Platform Testing 12/22/12
  • 2. Contents  Background aka "Real Life"  Cross-Platform  Testing  Add Windows Testing Under Unix  Test::MockObject  Test::MockModule  Running Unix unit tests under Windows  Future Plans For Testing  Summary and Links 2 Real Life Cross-Platform Testing 12/22/12
  • 3. Background aka "Real Life" Content Management System used at BBC to enter XML documents that are later transformed to make public websites  Client-side – GUI using WxPerl (WxWidgets) – WYSIWYG editing – Talks SOAP over HTTP to server – Runs under ActiveState Perl  Server-side – Handles SOAP requests – Stores document blobs in filesystem – Stores indexes, metadata in Oracle database – Runs under Solaris Perl  Usage – 100s of users – Time critical publishing : failure during release is not an option 3 Real Life Cross-Platform Testing 12/22/12
  • 4. Cross-Platform CMS code running on Windows and Solaris  Solaris perl 5.8.8 $ perl -V Summary of my perl5 (revision 5 version 8 subversion 8) configuration: Platform: osname=solaris, osvers=2.10, archname=sun4-solaris  Windows ASPerl 5.8 C:WINNT>perl –V Summary of my perl5 (revision 5 version 8 subversion 6) configuration: Platform: osname=MSWin32, osvers=4.0, archname=MSWin32-x86-multi-thread 4 Real Life Cross-Platform Testing 12/22/12
  • 5. Testing  Unit tests for dev  Automated overnight smoke testing of unit tests  Dev / Staging Test / Live environments  Manual release test on staging test area using Windows app Problems  Lots of tests for server side code, very few for client side because difficult to run 'use Wx' code on Unix in batch  Existing tests run on Unix, fail on Windows 5 Real Life Cross-Platform Testing 12/22/12
  • 6. Add Windows Testing Under Unix Need to write lots of client-side tests for 1) GUI WxPerl -> Gtk+ under Solaris ‘Use Wx’ was failing because no X display Problems with font sizing and window alignment Windows-specific components, e.g. ActiveX Altova editor  Installation Shortcuts, registry Win32::OLE, unzipping archives to Windows Apps dir etc. Solutions 1) Use Xvfb $ alias runxvfb='Xvfb :10 -dev vfb screen 0 1152x900x8 > /dev/null 2>&1 &' Lets you check code compile and call many routines But how do you test UI rendered properly - interpreting the virtual screen bitmaps is too hard! 1) Sandboxing and mocking Mock required Win32 functions Make them do file I/O to a sandbox area Test::MockObject - Perl extension for emulating troublesome interfaces Test::MockModule - Override subroutines in a module for unit testing 6 Real Life Cross-Platform Testing 12/22/12
  • 7. Test::MockObject 1  Helpers sub make_mock_obj_in_class { my $class = shift; my $obj = Test::MockObject->new; $obj->fake_module($class); $obj->fake_new($class); return $obj; } sub dump_mock_calls { my $mockobj = shift; my $i = 1; while ( my $name = $mockobj->call_pos($i) ) { diag " call $i: $name"; my @args = $mockobj->call_args($i); for (0 .. $#args) { diag ' arg '.($_ +1).': '; diag Dumper($args[$_]); } $i++; } } 7 Real Life Cross-Platform Testing 12/22/12
  • 8. Test::MockObject 2  Mocking my $wx = make_mock_obj_in_class( 'Wx' ); my $mock_WxPerlSplashProgress = make_mock_obj_in_class( 'Wx::Perl::SplashProgress' ); $mock_WxPerlSplashProgress->set_true(qw( SetLabelColour SetIcon Show SetValue Update Destroy )); $mock_WxPerlSplashProgress->mock( SetLabel => sub { diag ' SetLabel: '.$_[1] } ); $mock_Win32OLE = make_mock_obj_in_class( 'Win32::OLE' ); $mock_Win32OLE->mock( 'SpecialFolders', sub { shift } ); $mock_Win32OLE->mock( 'AppData', sub { return catdir(qw(data win32), 'Application Data') } ); $mock_Win32OLE->mock( 'StartMenu', sub { catdir(qw(data win32 startmenu)) } ); $mock_Win32OLE->mock( 'Desktop', sub { catdir(qw(data win32 desktop)) } ); $mock_Win32Shortcut = make_mock_obj_in_class( 'Win32::Shortcut' ); $mock_Win32Shortcut->mock( 'Load', sub { my ($self, $filename) = @_; $self->{content} = read_file($filename); return 1; } ); $mock_Win32Shortcut->mock( 'Path', sub { my ($self, $path) = @_; $self->{content} = $path; } ); $mock_Win32Shortcut->mock( 'Arguments', sub { my ($self, $args) = @_; $self->{content} .= ' '.$args . "rn"; } ); $mock_Win32Shortcut->mock( 'Save', sub { my ($self, $filename) = @_; write_file($filename, $self->{content} . "writetime ". gmtime() . "rn"); return 1; } ); $mock_Win32Shortcut->set_true(qw( ShowCmd Description IconLocation Close )); { no strict 'refs'; *{'Win32::Shortcut::SW_SHOWMINNOACTIVE'} = sub {}; } 8 Real Life Cross-Platform Testing 12/22/12
  • 9. Test::MockObject 3  Testing $mock_WxPerlSplashProgress->clear(); is( $i->_install_loginscript, 1, '$i->_install_loginscript' ); dump_mock_calls($mock_IFLDesktopLoginScript); $mock_IFLDesktopLoginScript->called_pos_ok( 3, 'install', 'called IFL::Desktop::LoginScript->install' ); dump_mock_calls($mock_WxPerlSplashProgress); $mock_WxPerlSplashProgress->called_pos_ok( 4, 'SetLabel', 'called Wx::Perl::SplashProgress->SetLabel' ); $mock_WxPerlSplashProgress->called_args_pos_is( 4, 2, 'Checking login script' ); $mock_WxPerlSplashProgress->called_pos_ok( 7, 'SetLabel', 'called Wx::Perl::SplashProgress->SetLabel' ); $mock_WxPerlSplashProgress->called_args_pos_is( 7, 2, 'Installing login script...' ); 9 Real Life Cross-Platform Testing 12/22/12
  • 10. Test::MockModule 1  Helper sub mock_module { my ($module,$options,@functions) = @_; my $no_auto = defined($options->{no_auto}) ? $options->{no_auto} : 1; my $create_new = defined($options->{create_new}) ? $options->{create_new} : 1; my $testmockmodule = new Test::MockModule($module, no_auto => $no_auto); my $object; if ($create_new) { $object = bless {}, $module; $testmockmodule->mock('new',sub { $logger->log($module,'new',@_); return $object }); } for my $function (@functions) { $testmockmodule->mock($function,sub { $logger->log($module,$function,@_) }); } no strict 'refs'; push @{$module . "::ISA"},'Exporter'; my $module_path = $module; $module_path =~ s{::}{/}xmsg; $module_path .= '.pm'; $INC{$module_path} = "1 (Inserted by mock_module())"; return $testmockmodule, $object; } 10 Real Life Cross-Platform Testing 12/22/12
  • 11. Test::MockModule 2  Mocking my ($mock_wx_activex_ie, $mock_wx_activex_ie_object) = mock_module('Wx::ActiveX::IE',{}); my ($mock_wx_activex_event, $mock_wx_activex_event_object) = mock_module('Wx::ActiveX::Event',{},@Wx::Event::EXPORT_OK); my ($mock_wx_panel,$mock_wx_panel_object) = mock_module('Wx::Panel',{}, qw( SetSizer )); my ($mock_wx_boxsizer,$mock_wx_boxsizer_object) = mock_module('Wx::BoxSizer',{}, qw( Add ));  Tests - use your objects as normal… then check call sequence my @mf_calls = $logger->filter({'FLIPClient::UI::MicroForms' => []}); my $call = shift(@mf_calls); is($call->{function},'set_template','position_change (' . $test->{name} . ') calls set_template'); ok($call->{args}->[1] =~ $test->{template},'position_change (' . $test->{name} . ') sets template'); $call = shift(@mf_calls); is($call->{function},'set_data','position_change (' . $test->{name} . ') calls set_data'); is_deeply($call->{args}->[1],$test->{data},'position_change (' . $test->{name} . ') sets data'); 11 Real Life Cross-Platform Testing 12/22/12
  • 12. Running Unix unit tests under Windows 1  Some libraries shared between Unix and Windows; not being tested properly client-side  Perl Portability – "perldoc perlport“ http://perldoc.perl.org/5.8.8/perlport.html "When the code will run on only two or three operating systems, you may need to consider only the differences of those particular systems. The important thing is to decide where the code will run and to be deliberate in your decision.“ – Only worrying about Windows and Unix; OpenVMS support is hard  binmode and chomp - binmode saves headaches on Windows like EOF ^Z; watch out for CR-LF  use File::Spec::Functions rather than Unix paths YES : my $path = rel2abs( catdir(qw( data local cache file.txt )); NO : my $path = './data/local/cache/file.txt'; 12 Real Life Cross-Platform Testing 12/22/12
  • 13. Running Unix unit tests under Windows 2  Generic configuration interface with platform-specific subclasses System.pm |-- System/Win32.pm |-- System/Unix.pm using File::Spec::Functions for paths  Change tests from path strings to regexes using a quote path separator my $script = $i->startup('remote'); NO : is( $script, 'scripts/FLIP_real.PL', '$i->startup("remote") script’ YES : $ps = ($^O eq 'MSWin32') ? "" : '/'; $qps = quotemeta $ps; like( $script, qr{ scripts [$qps] FLIP_real.pl z }xms, '$i- >startup("remote") script' ); Note PBP style regex  Actually run the tests on multiple platforms 13 Real Life Cross-Platform Testing 12/22/12
  • 14. Future Plans For Testing  Automate application release test under Windows – Win32::GuiTest (or pay for WinRunner) 14 Real Life Cross-Platform Testing 12/22/12
  • 15. Summary and Links  Summary – "perldoc perlport“ – Write cross-platform tests from the outset; convert old ones – Mock platform-specific GUI or system library calls – Automate tests (life is short) and get as much coverage as possible  Links – WxPerl http://wxperl.sourceforge.net/ – WxWidgets http://docs.wxwidgets.org/trunk/ – "Perl Testing: A Developer's Notebook" Ian Langworth & chromatic, O'Reilly Media, Inc., 2005 http://preview.tinyurl.com/5k6wnc Thank you. Any Questions? 15 Real Life Cross-Platform Testing 12/22/12