Testing in Ruby
Testing in Ruby
By Pavel Shutin. April 2013
Testing in Ruby
Pavel Shutin
• https://github.com/pluff
• http://linkedin.com/pub/pavel-shutin/56/440/168
• http://www.fac...
Testing in Ruby
Test Types
http://tiny.cc/0m0luw
•Functional
•Security
•Performance
•Recovery
•Regression
By Pavel Shutin....
Testing in Ruby
Manual Testing
http://tiny.cc/tk1luw
http://tiny.cc/9l1luw
•People are slow
•People can fail
•Manual testi...
Testing in Ruby
Automated Testing
•Fast!
•Doesn't have human mistake factor
•Allows to test at any point in time.
•Gives a...
Testing in Ruby
Too good to be true!
•Complex usecases require a lot of time to
represent in code.
•Frequently changing pi...
Testing in Ruby
Take best of both worlds
•Use automation for all criticalimportant
parts of application
•Use automation ev...
Testing in Ruby
Why should developers write tests?
•Make sure you did the right thing!
•Enforce yourself to do things righ...
Testing in Ruby
Testing tools in Ruby
• Minitest
• Rspec
• Cucumber
• Capybara
• FactoryGirl
By Pavel Shutin. April 2013
Testing in Ruby
Test structure
By Pavel Shutin. April 2013
Testing in Ruby
Test hooks & Lazy variables
By Pavel Shutin. April 2013
Testing in Ruby
TDD
Write tests as requirements to future code.
Ensure tests are failing
Write code until tests are green
...
Testing in Ruby
By Pavel Shutin. April 2013
Testing in Ruby
Stubs
http://tiny.cc/0v1tuw
By Pavel Shutin. April 2013
Testing in Ruby
Mocks
http://tiny.cc/zs1tuw
By Pavel Shutin. April 2013
Testing in Ruby
To stub or not to stub?
•Implementation matters? You can use
stubs!
•Don't test the code you didn't write....
Testing in Ruby
Cucumber and BDD
http://tiny.cc/hq1tuw
Given that a customer buys a blue garment
And I have two blue garme...
Testing in Ruby
F.I.R.S.T.
http://tiny.cc/e81tuw
•Fast (10 tests per second at least)
•Isolated (no reverse engineering)
•...
Testing in Ruby
Rubyist Library
1. The Ruby Programming Language
2. Metaprogramming Ruby: Program Like the Ruby
Pros
3. Th...
Testing in Ruby
Questions?
By Pavel Shutin. April 2013
Testing in Ruby
Thank you and Happy Testing
By Pavel Shutin. April 2013
Upcoming SlideShare
Loading in …5
×

Bsu on rails_testing

183 views
143 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
183
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Bsu on rails_testing

  1. 1. Testing in Ruby Testing in Ruby By Pavel Shutin. April 2013
  2. 2. Testing in Ruby Pavel Shutin • https://github.com/pluff • http://linkedin.com/pub/pavel-shutin/56/440/168 • http://www.facebook.com/pavel.shutin • publicshady@gmail.com By Pavel Shutin. April 2013
  3. 3. Testing in Ruby Test Types http://tiny.cc/0m0luw •Functional •Security •Performance •Recovery •Regression By Pavel Shutin. April 2013
  4. 4. Testing in Ruby Manual Testing http://tiny.cc/tk1luw http://tiny.cc/9l1luw •People are slow •People can fail •Manual testing applies to more-a-less finished system By Pavel Shutin. April 2013
  5. 5. Testing in Ruby Automated Testing •Fast! •Doesn't have human mistake factor •Allows to test at any point in time. •Gives an ability to quickly verify that you didn't broke anything! By Pavel Shutin. April 2013
  6. 6. Testing in Ruby Too good to be true! •Complex usecases require a lot of time to represent in code. •Frequently changing pieces of code require too much effort to maintain all tests. By Pavel Shutin. April 2013
  7. 7. Testing in Ruby Take best of both worlds •Use automation for all criticalimportant parts of application •Use automation everywhere where its reasonable •Let your real users to test the rest By Pavel Shutin. April 2013
  8. 8. Testing in Ruby Why should developers write tests? •Make sure you did the right thing! •Enforce yourself to do things right! •Make sure nobody will break it! •Catch any errors as soon as possible. By Pavel Shutin. April 2013
  9. 9. Testing in Ruby Testing tools in Ruby • Minitest • Rspec • Cucumber • Capybara • FactoryGirl By Pavel Shutin. April 2013
  10. 10. Testing in Ruby Test structure By Pavel Shutin. April 2013
  11. 11. Testing in Ruby Test hooks & Lazy variables By Pavel Shutin. April 2013
  12. 12. Testing in Ruby TDD Write tests as requirements to future code. Ensure tests are failing Write code until tests are green Review the code for refactoring Don't write a single line of code anymore! By Pavel Shutin. April 2013
  13. 13. Testing in Ruby By Pavel Shutin. April 2013
  14. 14. Testing in Ruby Stubs http://tiny.cc/0v1tuw By Pavel Shutin. April 2013
  15. 15. Testing in Ruby Mocks http://tiny.cc/zs1tuw By Pavel Shutin. April 2013
  16. 16. Testing in Ruby To stub or not to stub? •Implementation matters? You can use stubs! •Don't test the code you didn't write. Mock it! •You can test libraries too to ensure valid interface. •Really heavy method? Stub it. By Pavel Shutin. April 2013
  17. 17. Testing in Ruby Cucumber and BDD http://tiny.cc/hq1tuw Given that a customer buys a blue garment And I have two blue garments in stock And three black garments in stock. When he returns the garment for a replacement in black, Then I should have three blue garments in stock And two black garments in stock By Pavel Shutin. April 2013
  18. 18. Testing in Ruby F.I.R.S.T. http://tiny.cc/e81tuw •Fast (10 tests per second at least) •Isolated (no reverse engineering) •Repeatable (no randoms, no traces) •Self-validated (passed/failed only) •Timely (tests before code) By Pavel Shutin. April 2013
  19. 19. Testing in Ruby Rubyist Library 1. The Ruby Programming Language 2. Metaprogramming Ruby: Program Like the Ruby Pros 3. The Pragmatic Programmer: From Journeyman to Master 4. The Mythical Man-Month: Essays on Software Engineering 5. Code Complete: A Practical Handbook of Software Construction By Pavel Shutin. April 2013
  20. 20. Testing in Ruby Questions? By Pavel Shutin. April 2013
  21. 21. Testing in Ruby Thank you and Happy Testing By Pavel Shutin. April 2013

×