Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #329 -- Uninitialized value warnings in S::R::Commands #332

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

troglodyne
Copy link

It just wasn't setting sane defaults before running regex replace.
This commit additionally adds test coverage for the modified
subroutine, hopefully in the correct place.

I also added a block to properly include the libdir when running
the affected test via prove (so that you don't have to use -Ilib
or something like that) whenever we're not running the test via
'dzil test' or anything else where we've plopped the libs and
tests in a temporary '.build' directory.

It just wasn't setting sane defaults before running regex replace.
This commit additionally adds test coverage for the modified
subroutine, hopefully in the correct place.

I also added a block to properly include the libdir when running
the affected test via prove (so that you don't have to use -Ilib
or something like that) whenever we're not running the test via
'dzil test' or anything else where we've plopped the libs and
tests in a temporary '.build' directory.
Copy link
Owner

@teodesian teodesian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly concerned with the better messaging on die, but the other comments are good too.


unless($ENV{RELEASE_TESTING}) {
plan(skip_all=>"Author tests not required for installation.");
# Assume we're not using dzil test unless we're doing that
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are going to do this, just use FindBin.

or /{'?commands'?}->\{'?$command'?}/) {
pass("find $command");
$found_command = 1;
require_ok( "Selenium::Remote::Commands" ) || die;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would prefer a message with the die

}
}
if (!$found_command && $command !~ /Gecko/) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems profoundly silly to use pass/fail when one could simply fall through and do ok($found_command,"found $command") unless $command =~ /Gecko/

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't recall writing that bit... maybe I moved it?

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 73.688% when pulling eae31cc on troglodyne:SRD-329 into f9f6d94 on teodesian:master.

@troglodyne
Copy link
Author

K, updated the test for review commentary. Speeds up t/04-commands-implemented.t by 1s due to not reading in all three files every time you searched for one command.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 73.688% when pulling a4fa22a on troglodyne:SRD-329 into f9f6d94 on teodesian:master.

Copy link
Owner

@teodesian teodesian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refine the mocks, or re-record.

is($elems->[0]->get_value(),$array_elems[0]->get_value(), 'and the elements returned are the same');
{
no warnings 'redefine';
local *Selenium::Remote::WebElement::get_value = sub { return "zippy"; };
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a fan of redefining the method you then immediately call. Would be better to mock dependent methods in the method called.

is($elem->get_attribute('id'),'checky','Execute found proper element');
{
no warnings 'redefine';
local *Selenium::Remote::WebElement::get_attribute = sub { return "checky"; };
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same concern as above

@@ -23,6 +23,8 @@ my $ret;
my $elem;

LINK: {
no warnings 'redefine';
local *Selenium::Remote::WebElement::click = sub { return; };
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

fail("find $command");
}
my @cmds2see = keys( %{ Selenium::Remote::Commands->new->get_cmds } );
# You won't find the Gecko command in Selenium::Rmeote::Commands. This is intentional, so remove it from consideration.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mis-spelling rmeote

@@ -31,10 +31,15 @@ my %selenium_args = (
$driver->get('https://www.google.com');
my $input_text = $driver->find_element("//input[\@type='text']");

use Carp::Always;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this, or was this thrown in for debugging?

use Test::Selenium::Remote::Driver;
use Selenium::Remote::Mock::RemoteConnection;

use Carp::Always;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants