Browse Source

Fix TestHarness instantiation for DEMOLISH to fire properly

This was broken by f5b665c in #171.

Instantiating TestHarness, immediately calling one of its subroutines,
and de-referencing the returned hashref apparently also leads
TestHarness to immediately invoke DEMOLISH upon itself. Since we're
depending on the timing of DEMOLISH to be at the end of the .t file,
it was leading to empty mock recordings.

Separating the instantiation from the subroutine call and hash
de-referencing fixes the issue.
Daniel Gempesaw 11 years ago
parent
commit
3c244b67ff
5 changed files with 15 additions and 10 deletions
  1. 3 2
      t/01-driver.t
  2. 3 2
      t/02-webelement.t
  3. 3 2
      t/Firefox-Profile.t
  4. 3 2
      t/Test-Selenium-Remote-Driver-google.t
  5. 3 2
      t/lib/TestHarness.pm

+ 3 - 2
t/01-driver.t

@@ -14,9 +14,10 @@ use FindBin;
 use lib $FindBin::Bin . '/lib';
 use lib $FindBin::Bin . '/lib';
 use TestHarness;
 use TestHarness;
 
 
-my %selenium_args = %{ TestHarness->new(
+my $harness = TestHarness->new(
     this_file => $FindBin::Script
     this_file => $FindBin::Script
-)->base_caps };
+);
+my %selenium_args = %{ $harness->base_caps };
 
 
 my $driver = Selenium::Remote::Driver->new(%selenium_args);
 my $driver = Selenium::Remote::Driver->new(%selenium_args);
 my $website = 'http://localhost:63636';
 my $website = 'http://localhost:63636';

+ 3 - 2
t/02-webelement.t

@@ -9,9 +9,10 @@ use FindBin;
 use lib $FindBin::Bin . '/lib';
 use lib $FindBin::Bin . '/lib';
 use TestHarness;
 use TestHarness;
 
 
-my %selenium_args = %{ TestHarness->new(
+my $harness = TestHarness->new(
     this_file => $FindBin::Script
     this_file => $FindBin::Script
-)->base_caps };
+);
+my %selenium_args = %{ $harness->base_caps };
 
 
 my $driver = Selenium::Remote::Driver->new(%selenium_args);
 my $driver = Selenium::Remote::Driver->new(%selenium_args);
 my $website = 'http://localhost:63636';
 my $website = 'http://localhost:63636';

+ 3 - 2
t/Firefox-Profile.t

@@ -17,9 +17,10 @@ use FindBin;
 use lib $FindBin::Bin . '/lib';
 use lib $FindBin::Bin . '/lib';
 use TestHarness;
 use TestHarness;
 
 
-my %selenium_args = %{ TestHarness->new(
+my $harness = TestHarness->new(
     this_file => $FindBin::Script
     this_file => $FindBin::Script
-)->base_caps };
+);
+my %selenium_args = %{ $harness->base_caps };
 
 
 my $fixture_dir = $FindBin::Bin . '/www/';
 my $fixture_dir = $FindBin::Bin . '/www/';
 
 

+ 3 - 2
t/Test-Selenium-Remote-Driver-google.t

@@ -9,9 +9,10 @@ use FindBin;
 use lib $FindBin::Bin . '/lib';
 use lib $FindBin::Bin . '/lib';
 use TestHarness;
 use TestHarness;
 
 
-my %selenium_args = %{ TestHarness->new(
+my $harness = TestHarness->new(
     this_file => $FindBin::Script
     this_file => $FindBin::Script
-)->base_caps };
+);
+my %selenium_args = %{ $harness->base_caps };
 
 
 # Try to find
 # Try to find
 my $t = Test::Selenium::Remote::Driver->new(
 my $t = Test::Selenium::Remote::Driver->new(

+ 3 - 2
t/lib/TestHarness.pm

@@ -8,9 +8,10 @@ use Test::More;
 
 
 =head1 SYNOPSIS
 =head1 SYNOPSIS
 
 
-    my %selenium_args = %{ TestHarness->new(
+    my $harness = TestHarness->new(
         this_file => $FindBin::Script
         this_file => $FindBin::Script
-    )->base_caps };
+    );
+    my %selenium_args = %{ $harness->base_caps };
 
 
 =head1 DESCRIPTION
 =head1 DESCRIPTION