From: Ash Berlin Date: Sat, 7 Mar 2009 16:50:48 +0000 (+0000) Subject: Skip tests when java isn't installed/runable (IPC::Cmd) X-Git-Tag: 0.05 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FTest-WWW-Selenium-Catalyst.git;a=commitdiff_plain;h=0744bdf67407573b567261e48b0068210f2689c6 Skip tests when java isn't installed/runable (IPC::Cmd) --- diff --git a/Changes b/Changes index f410aae..33651e0 100644 --- a/Changes +++ b/Changes @@ -1,17 +1,21 @@ Revision history for Test-WWW-Selenium-Catalyst -0.04 4 Marh 2009 - Un-fark the dist so that the thing installs +0.05 - 2009/03/07 + - Use IPC::Cmd::can_run in tests to not have so many spurious failues due to + no smoke rigs having java installed -0.03 4 March 2009 - Allow a bit more configurability in selenium invocation and app - location +0.04 - 2009/03/05 + - Un-fark the dist so that the thing installs -0.02 6 March 2008 - Don't call $sel->start; this breaks stuff +0.03 - 2009/03/04 + - Allow a bit more configurability in selenium invocation and app + location -0.01 27 May 2007 - Mostly the same... released for wider testing. +0.02 - 2008/03/06 + - Don't call $sel->start; this breaks stuff -0.00_01 19 September 2006 - First version, released on an unsuspecting world. +0.01 - 2007/05/27 + - Mostly the same... released for wider testing. + +0.00_01 - 2006/09/19 + - First version, released on an unsuspecting world. diff --git a/Makefile.PL b/Makefile.PL index be8095f..48d5d60 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -14,10 +14,6 @@ requires( 'Catalyst::Utils' => 0, ); -# Old vers of CPAN dont set the env var. safer to assume we are running than -# ask about deps twice -my $under_cpan = $ENV{PERL5_CPANPLUS_IS_RUNNING} || - $ENV{PERL5_CPAN_IS_RUNNING} || - do { require CPAN; $CPAN::VERSION < 1.92 }; -$under_cpan or auto_install(); +test_requires 'IPC::Cmd' => '0.42'; + WriteAll(); diff --git a/README b/README index 47ae560..b3e72f7 100644 --- a/README +++ b/README @@ -34,6 +34,8 @@ You can also look for information at: COPYRIGHT AND LICENCE +Copyright (C) 2009 Ash Berlin + Copyright (C) 2006 Jonathan Rockway This program is free software; you can redistribute it and/or modify it diff --git a/lib/Test/WWW/Selenium/Catalyst.pm b/lib/Test/WWW/Selenium/Catalyst.pm index fa177bd..014694f 100644 --- a/lib/Test/WWW/Selenium/Catalyst.pm +++ b/lib/Test/WWW/Selenium/Catalyst.pm @@ -24,7 +24,7 @@ Test::WWW::Selenium::Catalyst - Test your Catalyst application with Selenium =cut -our $VERSION = '0.04'; +our $VERSION = '0.05'; =head1 DEVELOPERISH RELEASE @@ -175,7 +175,7 @@ sub import { $DEBUG = $d; } - unless ($args{-no_seleniun_server}) { + unless ($args{-no_selenium_server}) { $class->_start_server($args{-selenium_args}) or croak "Couldn't start selenium server"; } return 1; @@ -246,6 +246,7 @@ END { if($sel_pid){ if($www_selenium){ diag("Shutting down Selenium Server $sel_pid") if $DEBUG; + $www_selenium->stop(); $www_selenium->do_command('shutDown'); undef $www_selenium; } diff --git a/t/01-live.t b/t/01-live.t index 2ad081b..0cb2d87 100644 --- a/t/01-live.t +++ b/t/01-live.t @@ -2,26 +2,52 @@ # 01-live.t # Copyright (c) 2006 Jonathan Rockway -use Test::More tests => 79; +use Test::More tests => 80; use FindBin; use lib "$FindBin::Bin/lib"; -use Test::WWW::Selenium::Catalyst 'TestApp', - -selenium_args => '-singleWindow'; - -diag("You need to have firefox-bin in your path for this to work!"); - -my $sel = Test::WWW::Selenium::Catalyst->start({browser => '*firefox'}); - -$sel->open_ok('/'); -$sel->text_is("link=Click here", "Click here"); -$sel->click_ok("link=Click here"); -$sel->wait_for_page_to_load_ok("30000", 'wait'); -for my $i (1..10){ - $sel->open_ok("/words/$i"); - $sel->is_text_present_ok( - qq{Here you'll find all things "words" printed $i time(s)!}); - - for my $j (1..$i){ - $sel->is_text_present_ok("$j: foo bar baz bat qux quux"); + +use IPC::Cmd qw/can_run/; + +my $have_apps = + can_run('java') && + ( can_run('firefox') || can_run('firefox-bin') ); + +SKIP: { + unless ($have_apps) { + # Missing Java or firefox, just do a use_ok test + use_ok('Test::WWW::Selenium::Catalyst', 'TestApp', + -no_selenium_server => 1); + skip "java and firefox requires for further testing", 79; + } else { + diag("You need to have firefox(-bin) in your path for this to work!"); + + my $port = int(20000+rand()*20000); + # Try to cope with case when selenium is already running or something is on port 4444 + my $sel = eval { + + use_ok('Test::WWW::Selenium::Catalyst', 'TestApp', + -selenium_args => "-singleWindow -port $port"); + + Test::WWW::Selenium::Catalyst->start( { + browser => '*firefox', + selenium_port => $port + } ); + }; + + skip $@, 80 if $@; + + $sel->open_ok('/'); + $sel->text_is("link=Click here", "Click here"); + $sel->click_ok("link=Click here"); + $sel->wait_for_page_to_load_ok("30000", 'wait'); + for my $i (1..10){ + $sel->open_ok("/words/$i"); + $sel->is_text_present_ok( + qq{Here you'll find all things "words" printed $i time(s)!}); + + for my $j (1..$i){ + $sel->is_text_present_ok("$j: foo bar baz bat qux quux"); + } } + } }