Your SlideShare is downloading. ×
Integration Testing Practice using Perl
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Integration Testing Practice using Perl

2,637
views

Published on

YAPC::Asia 2013

YAPC::Asia 2013

Published in: Technology

0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,637
On Slideshare
0
From Embeds
0
Number of Embeds
7
Actions
Shares
0
Downloads
11
Comments
0
Likes
4
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Integration Testing Practice using Perl Masaki Nakagawa / @ikasam_a DeNA Co., Ltd.
  • 2. About Me • Masaki Nakagawa • @ikasam_a • github.com/masaki • metacpan.org/author/MASAKI • Yokohama.pm
  • 3. Ad.
  • 4. http://gihyo.jp/magazine/wdpress/archive/2013/vol75
  • 5. http://gihyo.jp/book/2013/978-4-7741-5864-8
  • 6. http://yapcasia.org/2013/talk/show/9c756568-ea92-11e2-ba88-5f716aeab6a4 What's new in Carton & cpanm (11:40 ~ 12:00)
  • 7. http://atnd.org/events/40914
  • 8. Software Engineer in Test at DeNA Masaki Nakagawa / @ikasam_a DeNA Co., Ltd. http://www.slideshare.net/masaki/software-engineer-in-test-at-dena
  • 9. Testing Casual Talks #2 2013/11/xx
  • 10. Works • DeNA Co.,Ltd. • SWET Group, Platform System Dept. • Founder of Platform QA Team (2012/01~) • Manager of SWET Group (2013/08~)
  • 11. http://dena.com/topics/2013/07/swettechtalk33.php with @shyouhei
  • 12. YAPC::Asia Tokyo 2013 特別座談会 「Rubyの良いところ語ってください ∼そんなPerlで大丈夫か?∼」 (13:00 ~ 14:00) http://yapcasia.org/2013/talk/show/c6b08f02-f293-11e2-ba15-895a6aeab6a4
  • 13. Roles • SWET (Software Engineer in Test) • TE (Test Engineer)
  • 14. What is SWET? • a developer role for testing • write test framework • build test environments • write test codes
  • 15. http://en.wikipedia.org/wiki/SET
  • 16. http://googletesting.blogspot.jp/2011/02/how-google- tests-software-part-two.html
  • 17. Several Names • SWET @DeNA • SET (Software Engineer in Test) @Google • SDET (Software Development Engineer in Test) @Microsoft
  • 18. Google’s “SET” • Google Testing Blog • http://googletesting.blogspot.com • How Google Tests Software • http://googletesting.blogspot.jp/2011/01/how-google-tests-software.html
  • 19. Developer Productivity • to improve productivity • Base Technology • Development Infrastructure • as SWET • support developer testing • support development with tests
  • 20. Testing Activities SHOULD be in Developments
  • 21. SWET Group Mission Statement • For platform engineers • To develop new features • Should keep the quality of platform system
  • 22. About SWET Group • To verify the Platform System • To write AUTOMATION tests • To improve Platform System quality is NOT a tester, is a TEST ENGINEER
  • 23. What is SWET? • a developer role for testing • write test framework • build test environments • write test codes
  • 24. How to ?
  • 25. Classification of Testing Perspective Target How What
  • 26. Perspective •Developer Testing •Acceptance Testing Developer or User (Customer)
  • 27. Target •Unit Testing •Integration Testing One or More
  • 28. How •Black Box Testing •White Box Testing •Gray Box Testing Techniques for writing tests
  • 29. What •Functional Testing •Non-Functional Testing • Performance / Stress / Usability / ... the Purpose of testing
  • 30. Classification of Testing Perspective Target How What
  • 31. Target •Unit Testing •Integration Testing One or More
  • 32. Unit Testing • What is “Unit” ? • METHODs in module • COMPONENTs in system • ... • Focus to input/output of unit
  • 33. Integration Testing • What is “Integration” • MODULEs (= component) • COMPONENTs (= system) • ... • Consider interaction/orchestration
  • 34. Interaction • Unit Testing • ONLY Focus to Test Target • Mocking/Stubbing OTHERs • Integration Testing • in Real Environments
  • 35. Case Study
  • 36. (case-1) Web API • HTTP JSON-RPC API • Interaction & Integration • API Server Modules • API Server, DB, Cache Server
  • 37. API Server module module module API ServerAPI Server DB API ServerAPI Server Cache Test Client
  • 38. Conditions • (IN) HTTP Request to API Server • (OUT) JSON Response from API Server
  • 39. HTTP Client •LWP::UserAgent •Furl
  • 40. JSONValidation • JSON + Test::Deep family • T::D::Matcher,T::D::Cond • use JSON-Schema • https://github.com/zigorou/perl-JSV
  • 41. API Server module module module API ServerAPI Server DB API ServerAPI Server Cache Test Client Gray Box Fixture
  • 42. Gray Box Fixture • DB / Cache Manipulation • insert test-case specific data • delete cache for continuous tests
  • 43. API ServerAPI ServerAPI Server module module module API ServerAPI Server DB API ServerAPI Server Cache Test Client Specific Server Request
  • 44. Specific Server Request • LWP::UserAgent::DNS::Hosts • Furl + “inet_aton” option • programmable local DNS (MyDNS)
  • 45. Dump Messages • LWP keeps previous request • as HTTP::Response::request() • Furl + “capture_request” option
  • 46. (case-2) Web Application • Interaction & Integration • Web App Modules • like MVC • Web App, DB, Cache Server
  • 47. Web Application M V C API ServerAPI Server DB API ServerAPI Server Cache Test Browser
  • 48. Conditions • (IN) HTTP Request to Web App • (OUT) HTML Response from Web App
  • 49. Browser / User Agent •WWW::Mechanize •Selenium::Remote::Driver •Wight •Brownie
  • 50. use Test::More; use Brownie::Session; my $session = Brownie::Session->new( driver => 'Mechanize', app_host => 'http://app.example.com/', ); $session->visit('/'); is $session->title => 'Title'; $session->fill_in('User Name' => 'brownie'); $session->fill_in('Email Address' => 'brownie@example.com'); $session->click_button('Login'); like $session->source => qr/Welcome (.+)/; done_testing; e.g.) Brownie
  • 51. Test Browser Test Browser Web Application M V C API ServerAPI Server DB API ServerAPI Server Cache Switch Browser
  • 52. Switch Browser • Browser can’t touch HTTP Header • Emulator can’t parse JavaScript • Save/Restore pseudo browser state
  • 53. Other Modules • Test::Ika (RSpec for Perl) • Test::Requires::Env • App::envfile • Config::Pit
  • 54. Test::Ika use Test::Ika; use Test::More; describe 'nekokak API' => sub { my $client; before_each { $client = NekokakClient->new(icon => 1); }; it 'should return response with icon' => sub { my $res = $client->request(method => 'dis'); ok $res->{icon}; }; }; runtests;
  • 55. Test::Requires::Env use Test::Requires::Env qw( USERNAME PASSWORD );
  • 56. Questions?