pl/sql unit testing with ruby
DESCRIPTION
Presentation at EMEA Harmony Oracle user groups conference in TallinnTRANSCRIPT
![Page 1: PL/SQL unit testing with Ruby](https://reader034.vdocuments.mx/reader034/viewer/2022052321/55593043d8b42a4f3d8b48e6/html5/thumbnails/1.jpg)
PL/SQL Unit Testingwith Ruby
![Page 2: PL/SQL unit testing with Ruby](https://reader034.vdocuments.mx/reader034/viewer/2022052321/55593043d8b42a4f3d8b48e6/html5/thumbnails/2.jpg)
Raimonds Simanovskis
github.com/rsim
![Page 3: PL/SQL unit testing with Ruby](https://reader034.vdocuments.mx/reader034/viewer/2022052321/55593043d8b42a4f3d8b48e6/html5/thumbnails/3.jpg)
What is good code?
Correct
Fast enough
Maintainable
Test functionality!
Testperformance!
Test afterchanges!
![Page 4: PL/SQL unit testing with Ruby](https://reader034.vdocuments.mx/reader034/viewer/2022052321/55593043d8b42a4f3d8b48e6/html5/thumbnails/4.jpg)
How is it done?try something...
dbms_output.put_line(...)
testers should test,that’s their job
it is obvious thatthere are no bugs :)
![Page 5: PL/SQL unit testing with Ruby](https://reader034.vdocuments.mx/reader034/viewer/2022052321/55593043d8b42a4f3d8b48e6/html5/thumbnails/5.jpg)
What are typicalproblems?
“trying” and not testing
tests are not repeatable
manual verification of results
testing is done too late in development
![Page 6: PL/SQL unit testing with Ruby](https://reader034.vdocuments.mx/reader034/viewer/2022052321/55593043d8b42a4f3d8b48e6/html5/thumbnails/6.jpg)
Types of testsunit tests
integration tests
performance & load tests
exploratory & usability tests
programmer’sresponsibility
![Page 7: PL/SQL unit testing with Ruby](https://reader034.vdocuments.mx/reader034/viewer/2022052321/55593043d8b42a4f3d8b48e6/html5/thumbnails/7.jpg)
Test Driven Development
Write test
Run test
Write code
Run test
Refactoring
![Page 8: PL/SQL unit testing with Ruby](https://reader034.vdocuments.mx/reader034/viewer/2022052321/55593043d8b42a4f3d8b48e6/html5/thumbnails/8.jpg)
Good unit testsAutomatic, run fast
Wide code coverage including edge cases
Repeatable
Independent from execution order
Using real and understandable test data
![Page 9: PL/SQL unit testing with Ruby](https://reader034.vdocuments.mx/reader034/viewer/2022052321/55593043d8b42a4f3d8b48e6/html5/thumbnails/9.jpg)
How to do itwhen programming in
PL/SQL ?
![Page 10: PL/SQL unit testing with Ruby](https://reader034.vdocuments.mx/reader034/viewer/2022052321/55593043d8b42a4f3d8b48e6/html5/thumbnails/10.jpg)
utPLSQLcreated by Steven Feuerstein, 1999
based on “xUnit”-style frameworks
not maintained anymore :(
![Page 11: PL/SQL unit testing with Ruby](https://reader034.vdocuments.mx/reader034/viewer/2022052321/55593043d8b42a4f3d8b48e6/html5/thumbnails/11.jpg)
ExampleSubstring from startuntil end position
![Page 12: PL/SQL unit testing with Ruby](https://reader034.vdocuments.mx/reader034/viewer/2022052321/55593043d8b42a4f3d8b48e6/html5/thumbnails/12.jpg)
Tests
![Page 13: PL/SQL unit testing with Ruby](https://reader034.vdocuments.mx/reader034/viewer/2022052321/55593043d8b42a4f3d8b48e6/html5/thumbnails/13.jpg)
Results
![Page 14: PL/SQL unit testing with Ruby](https://reader034.vdocuments.mx/reader034/viewer/2022052321/55593043d8b42a4f3d8b48e6/html5/thumbnails/14.jpg)
Visual testing tools
Quest Code Tester SQL Developer 2.1
![Page 15: PL/SQL unit testing with Ruby](https://reader034.vdocuments.mx/reader034/viewer/2022052321/55593043d8b42a4f3d8b48e6/html5/thumbnails/15.jpg)
Why used just by few?
too large / too verbose test code?
hard to read, too much noise?
hard to test complex cases?
no best practices how to write tests?
nobody is using, why should I use?
![Page 16: PL/SQL unit testing with Ruby](https://reader034.vdocuments.mx/reader034/viewer/2022052321/55593043d8b42a4f3d8b48e6/html5/thumbnails/16.jpg)
ruby-plsql-specideal language for writing tests
powerful testing toolswith “readable” syntaxRSpec
ruby-plsql library for callingPL/SQL procedures
from Ruby
![Page 17: PL/SQL unit testing with Ruby](https://reader034.vdocuments.mx/reader034/viewer/2022052321/55593043d8b42a4f3d8b48e6/html5/thumbnails/17.jpg)
ruby-plsql-specDemo
![Page 18: PL/SQL unit testing with Ruby](https://reader034.vdocuments.mx/reader034/viewer/2022052321/55593043d8b42a4f3d8b48e6/html5/thumbnails/18.jpg)
Benefitscompact, readable syntax
powerful features also for complex tests
best practices from Ruby community
based on needs from real projects
opensource – “free as in beer” :)
![Page 19: PL/SQL unit testing with Ruby](https://reader034.vdocuments.mx/reader034/viewer/2022052321/55593043d8b42a4f3d8b48e6/html5/thumbnails/19.jpg)
Linkshttp://blog.rayapps.com/2009/11/27/oracle-
plsql-unit-testing-with-ruby/
http://blog.rayapps.com/2010/01/06/screencasts-of-oracle-plsql-unit-testing-with-
ruby/
http://github.com/rsim/ruby-plsql-spec