Software Testing

Post on 30-Nov-2014

294 views 0 download

Tags:

description

Talk given at Yelster Digital workshop in 2011.

Transcript of Software Testing

Software Testing

Wallace Reis | wreisTuesday, October 08, 2013

Software Testing

Wallace Reis | wreisTuesday, October 08, 2013

Tuesday, October 08, 2013

Tuesday, October 08, 2013

Tuesday, October 08, 2013

Tuesday, October 08, 2013

Tuesday, October 08, 2013

Development processes

Tuesday, October 08, 2013

Perl Testing?

Tuesday, October 08, 2013

CPAN:

*modules;*frameworks;*and toolkits;

Tuesday, October 08, 2013

Testing methods

Tuesday, October 08, 2013

Black-box

Tuesday, October 08, 2013

Input Output

Tuesday, October 08, 2013

use strict;use warnings;use Test::More;

use_ok 'Module';

ok(my $test = Module->new);ok($test->sum(1,2) == 3);ok($test->sum(3,2) == 5);

done_testing;

Tuesday, October 08, 2013

White-box

Tuesday, October 08, 2013

sub sum { my ( $self, $x, $y ) = @_; return undef unless defined $x && defined $y; if ( $x == 0 ) { return $y; } elsif ( $y == 0 ) { return $x; } else { return $x + $y; }}

Tuesday, October 08, 2013

use strict;use warnings;use Test::More;

use_ok 'Module';

ok(my $test = Module->new);ok($test->sum(0,2) == 2);ok($test->sum(1,0) == 1);ok(!$test->sum(1));ok(!$test->sum());

done_testing;

Tuesday, October 08, 2013

Testing levels

Tuesday, October 08, 2013

Unit

Tuesday, October 08, 2013

use strict;use warnings;use Test::More;

my $search_comp;BEGIN { use_ok 'I5::123people::Website'; $search_comp = 'I5::123people::Website::Model::Search'; use_ok $search_comp;}

foreach my $source ( qw{http://foo.bar.com https://foo.bar.com/ ftp://foo.bar.com ftps://foo.bar.com/ ftp://wreis@foo.bar.com/ ftp://wreis:passwd@foo.bar.com/}) { is($search_comp->extract_domain($source), 'foo.bar.com');}

# ...

done_testing;

Tuesday, October 08, 2013

Mock objects

and

Method stubs

Tuesday, October 08, 2013

use strict;use warnings;use Test::More;use MooseX::Declare;

my $class = class extends Catalyst::Model with Catalyst::Component::InstancePerRequest{ has balance => ( ... );

method deposit (Num $amount) { $self->balance( $self->balance + $amount ); }

method get_session_id { return ‘maow98ua92’ }};

ok($class->name->new);

my $role = role { ... };

#...

done_testing;

Tuesday, October 08, 2013

Integration

Tuesday, October 08, 2013

use strict;use warnings;use Test::More;use Test::WWW:::Mechanize;

my $data = { name => 'MyFoo', description => 'MyFoo é uma...',};

my $mech = Test::WWW::Mechanize->new;

$mech->get_ok('/foo');$mech->submit_form_ok({ with_fields => $data, button => 'submit',}, 'form submit...');

$mech->content_contains($data->{$_}) for qw/name description/;

# ...

done_testing;

Tuesday, October 08, 2013

Regression

Tuesday, October 08, 2013

Acceptance

Tuesday, October 08, 2013

use strict;use warnings;use Test::More;use lib 't/lib';use PeopleTest;

my $people_test = PeopleTest->new;$people_test->log_disable('error');my $mech = $people_test->get_mech;

check_error_400('/a8i2k282543jwd09awdj', 404);check_error_400('/page/a8i2k282543jwd09awdj', 404);

sub check_error_400 { my ( $path, $code ) = @_; my $res = $mech->get($path); ok($res->code == $code) or diag($res->code); is($res->header('Pragma'), 'no-cache'); is($res->header('Cache-Control'), 'no-cache'); ok(defined $res->header('X-Robots-Tag')); like($res->content, qr{meta.*robots.*noindex}i);}

done_testing;

Tuesday, October 08, 2013

User acceptance

Tuesday, October 08, 2013

Platform

Tuesday, October 08, 2013

$ CATALYST_SERVER=‘http://localhost:3000/’ prove -lr t

$ CATALYST_SERVER=‘http://www.123people.biz/’ prove -lr t

$ CATALYST_SERVER=‘http://www.123people.com/’ prove -lr t

Tuesday, October 08, 2013

Coverage

Tuesday, October 08, 2013

Devel::Cover

Tuesday, October 08, 2013

Tuesday, October 08, 2013

More info...

Tuesday, October 08, 2013

Tuesday, October 08, 2013

Tuesday, October 08, 2013

Tuesday, October 08, 2013

Thank you!Discussion?

Tuesday, October 08, 2013