瀏覽代碼

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 年之前
父節點
當前提交
3c244b67ff
共有 5 個文件被更改,包括 15 次插入10 次删除
  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 TestHarness;
 
-my %selenium_args = %{ TestHarness->new(
+my $harness = TestHarness->new(
     this_file => $FindBin::Script
-)->base_caps };
+);
+my %selenium_args = %{ $harness->base_caps };
 
 my $driver = Selenium::Remote::Driver->new(%selenium_args);
 my $website = 'http://localhost:63636';

+ 3 - 2
t/02-webelement.t

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

+ 3 - 2
t/Firefox-Profile.t

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

+ 3 - 2
t/lib/TestHarness.pm

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