Perl Testing Consideration (seen from other languages)

32
Perl Testing Consideration (seen from other languages) Masaki Nakagawa YAPC::Asia 2011 Tokyo (yapcasia.org/2011/talk/80) 20111014日金曜日

description

YAPC::Asia Tokyo 2011

Transcript of Perl Testing Consideration (seen from other languages)

Page 1: Perl Testing Consideration (seen from other languages)

Perl Testing Consideration

(seen from other languages)

Masaki Nakagawa

YAPC::Asia 2011 Tokyo (yapcasia.org/2011/talk/80)

2011年10月14日金曜日

Page 2: Perl Testing Consideration (seen from other languages)

Profile

• Masaki Nakagawa

• @ikasam_a

• metacpan.org/author/MASAKI

• MC of Yokohama.pm (yokohama.pm.org)

• github.com/masaki

• socialbios.com/ikasam_a

• “Pushing the Team B”

2011年10月14日金曜日

Page 3: Perl Testing Consideration (seen from other languages)

Thank you !

ameblo.jp/yuki-kashiwagi-we/image-11002817849-11452563522.html2011年10月14日金曜日

Page 4: Perl Testing Consideration (seen from other languages)

Works

• Embedded Development w/ C++

• WebApp. Development w/ Ruby

• Project Management (small)

• New Business Development

• www.ricoh.co.jp/ucs/

• www.ricoh.co.jp/ucs/P3000/

2011年10月14日金曜日

Page 5: Perl Testing Consideration (seen from other languages)

Embedded Development

• “Hardware Driven”

• “The Waterfall”

• Development Process

• QA Process

• Systematic Testing

2011年10月14日金曜日

Page 6: Perl Testing Consideration (seen from other languages)

Classification of Testing

Perspective Target

How What

2011年10月14日金曜日

Page 7: Perl Testing Consideration (seen from other languages)

Perspective

• Developer Testing

• Acceptance Testing

Developer or User (Customer)

2011年10月14日金曜日

Page 8: Perl Testing Consideration (seen from other languages)

Target

• Unit Testing

• Integration Testing

One or More

2011年10月14日金曜日

Page 9: Perl Testing Consideration (seen from other languages)

How

• Black Box Testing

• White Box Testing

Techniques for writing tests

2011年10月14日金曜日

Page 10: Perl Testing Consideration (seen from other languages)

What

• Functional Testing

• Non-Functional Testing

• Performance / Stress / Usability / ...

the Purpose of testing

2011年10月14日金曜日

Page 11: Perl Testing Consideration (seen from other languages)

Testing Framework

1. Helping to write tests

2. Executing tests

3. Reporting test results

2011年10月14日金曜日

Page 13: Perl Testing Consideration (seen from other languages)

e.g.) RSpec

1. describe ... it ...

2. $ rspec ...

3. Spec::Runner::Formatter

2011年10月14日金曜日

Page 14: Perl Testing Consideration (seen from other languages)

e.g.) Cucumber

1. Given ... When ... Then ...

2. $ cucumber ...

3. Cucumber::Formatter

2011年10月14日金曜日

Page 15: Perl Testing Consideration (seen from other languages)

Many Frameworks

2011年10月14日金曜日

Page 16: Perl Testing Consideration (seen from other languages)

Perl Testing

1. Test::More, Test::Class,Test::Base, Test::Spec, ...

2. $ prove ... (TAP::Harness)

3. TAP (TAP::Formatter)

2011年10月14日金曜日

Page 17: Perl Testing Consideration (seen from other languages)

Perl has TAP

2011年10月14日金曜日

Page 18: Perl Testing Consideration (seen from other languages)

TAP

• testanything.org

• “the Test Anything Protocol”

• “is a simple text-based interface”

1..4ok 1 - Input file openednot ok 2 - First line of the input validok 3 - Read the rest of the filenot ok 4 - Summarized correctly # TODO Not written yet

testanything.org/wiki/index.php/Main_Page2011年10月14日金曜日

Page 19: Perl Testing Consideration (seen from other languages)

Perl <3 TAP

• From any test description

• e.g.) Test::Class, Test::Base, Test::Spec

• Convert results to non-TAP format

• e.g.) TAP::Formatter::JUnit

• Easy to write test helpers

• e.g.) Test::Exception, Test::Deep, ...

2011年10月14日金曜日

Page 20: Perl Testing Consideration (seen from other languages)

Rails Testing

gihyo.jp/magazine/wdpress/archive/2011/vol612011年10月14日金曜日

Page 21: Perl Testing Consideration (seen from other languages)

Rails Testing

• Perspective

• UnitTest, End-to-End

• Frameworks

• Test::Unit (+ Shoulda), RSpec, Cucumber

• Browser Integration

• Capybara (rack-test, Selenium, Envjs, ...)

• Test Double

• rspec-mocks, rr, WebMock

2011年10月14日金曜日

Page 22: Perl Testing Consideration (seen from other languages)

Catalyst

• Catalyst::Test

• Test::WWW::Mechanize::Catalyst

• Test::WWW::Selenium::Catalyst

2011年10月14日金曜日

Page 23: Perl Testing Consideration (seen from other languages)

Plack

• Plack::Test

• Test::WWW::Mechanize::PSGI

2011年10月14日金曜日

Page 24: Perl Testing Consideration (seen from other languages)

Browser Integration

• WWW:: + WAF Customization

• WWW::Mechanize

• WWW::Selenium (Selenium-RC)

• not yet for testing

• WWW::HtmlUnit

• Selenium::Remote::Driver (WebDriver)

2011年10月14日金曜日

Page 25: Perl Testing Consideration (seen from other languages)

Test Double

• Mock

• Test::MockObject

• Test::Mock::Recorder

• Stub

• Test::Mock::Guard

• Test::Mock::LWP::Dispatch

xunitpatterns.com/Test%20Double.html

2011年10月14日金曜日

Page 26: Perl Testing Consideration (seen from other languages)

Test Double

• Test::Double (under construction)

• 0.01 released !

• metacpan.org/release/Test-Double

• github.com/masaki/Test-Double

• Mocks and Stubs

• mock out w/ mocha style

• stub out w/ rr style

• Collaborators Welcome!!!

xunitpatterns.com/Test%20Double.html

2011年10月14日金曜日

Page 27: Perl Testing Consideration (seen from other languages)

Test Double

• Spy

• DBD::Mock

• Fake

• Test::mysqld

• Test::TCP

xunitpatterns.com/Test%20Double.html

2011年10月14日金曜日

Page 28: Perl Testing Consideration (seen from other languages)

Descriptive Frameworks

• Test::More

• Test::Class (xUnit style)

• Test::Declare / Test::More + “subtest”

• Test::Spec (RSpec 1 compat.)

• Test::Base (Parameterized Tests)

• Test::Cukes / Test::BDD::Cucumber(Cucumber clone)

2011年10月14日金曜日

Page 29: Perl Testing Consideration (seen from other languages)

Weakness

• Expectation and Verification

• vs. rr, rspec-mocks, mocha, ...

• Browser Integration API

• vs. Capybara, Webrat, ...

• Naming of Test Double modules

• Test::Mock::Guard is “Stub” module

2011年10月14日金曜日

Page 30: Perl Testing Consideration (seen from other languages)

Comparision

• Pros

• TAP-based Test Description

• Many Helpful Modules

• Cons

• Non-Uniform Browser Integration

• Poor Expectation and Verification

2011年10月14日金曜日

Page 31: Perl Testing Consideration (seen from other languages)

Conclusions

• About Testing

• 4 Classifications

• 3 Elements in Frameworks

• Perl and Ruby/Rails Testing Environments

• Perl has TAP and Many Great Modules

• Learn and Steal MORE from Ruby/Rails

• Write More Descriptively2011年10月14日金曜日

Page 32: Perl Testing Consideration (seen from other languages)

Thank you!Questions?

2011年10月14日金曜日