Slides

339
-1

Published on

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

  • Be the first to like this

No Downloads
Views
Total Views
339
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
17
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Slides

  1. 1. Effective Test Driven Database Development <ul><ul><li>Gojko Adzic </li></ul></ul><ul><ul><li>http://gojko.net </li></ul></ul><ul><ul><li>[email_address] </li></ul></ul><ul><ul><li>twitter.com/gojkoadzic </li></ul></ul>
  2. 2. Database somehow always sticks out
  3. 3. Lots of teams struggle with Database testing... <ul><li>Bad tools </li></ul><ul><li>Inherently hard to test </li></ul><ul><li>Changes are persistent </li></ul><ul><li>Attitude of DB Specialists </li></ul>
  4. 4. Full build with all integration tests is the only thing you can really trust ... but it is not the most practical thing to run all the time
  5. 5. DB management <ul><li>Dedicated instances for developers are best </li></ul><ul><li>One development DB can also work ok </li></ul><ul><li>Build + n*integrations must always be separate </li></ul>
  6. 6. Don't count on the DB being empty Tests will be much more effective if they can ignore trash
  7. 7. Generate the glue code and bring the two worlds closer together
  8. 8. Don't fight against database features, use them! Run tests in transactions!
  9. 9. Isolate non-transactional tests and run them overnight
  10. 10. Do not depend on the order of test execution
  11. 11. Prepare everything you need for an isolated test
  12. 12. Prepare everything you need... <ul><li>Known state of small development databases </li></ul><ul><ul><li>Link to files </li></ul></ul><ul><ul><li>Trash and restore DB </li></ul></ul><ul><li>Start with a clean DB and Load data with DbUnit </li></ul><ul><li>Set up data for a specific test and roll back later </li></ul><ul><li>Ideally don't suppose that the DB is empty </li></ul>
  13. 13. ORM is not magic!
  14. 14. DBFIT: Test Driven DB Development Made Easy FIT+FitNesse+DB Fixtures http://sourceforge.net/projects/dbfit http://fitnesse.info/dbfit
  15. 15. Why DbFit? <ul><li>Manipulate data in a relational model </li></ul><ul><li>Provides all the plumbing </li></ul><ul><ul><li>Transaction management </li></ul></ul><ul><ul><li>Smart features based on meta-data </li></ul></ul><ul><ul><li>Parameter mapping </li></ul></ul><ul><ul><li>“wizards” for regression tests </li></ul></ul><ul><li>Because it runs inside FitNesse, already integrated with a lot of other tools/libraries </li></ul>
  16. 16. Use DbFit to: <ul><li>Write and execute DB Unit tests </li></ul><ul><li>Prepare/verify Java or .NET integration tests </li></ul><ul><ul><li>.NET: Sql Server, Oracle, (DB2)‏ </li></ul></ul><ul><ul><li>Java: Mysql, Oracle, (DB2, SQL Server, Derby)‏ </li></ul></ul>
  17. 17. Simple commands <ul><li>Execute procedure </li></ul><ul><li>Query </li></ul><ul><li>Execute </li></ul><ul><li>Insert </li></ul><ul><li>Update </li></ul>
  18. 18. FitNesse symbols directly mapped to bind variables <ul><li>Retrieve auto-generated keys and use them directly </li></ul><ul><li><< and >> available in Java as well </li></ul><ul><li>Already mapped to bind variables </li></ul>
  19. 19. Advanced features <ul><li>Inspect queries, tables or procs to automatically generate test tables and regression tests </li></ul><ul><li>Store and compare queries </li></ul><ul><li>Standalone mode for full control </li></ul>
  20. 20. DbFit 2.0 <ul><li>Upcoming release in April </li></ul><ul><ul><li>Support for command timeouts </li></ul></ul><ul><ul><li>Better architecture, more flexible for different test runners </li></ul></ul><ul><ul><li>Integration with Trinidad </li></ul></ul><ul><ul><li>Support for Db2, Derby, HSQL </li></ul></ul>
  21. 21. Image credits <ul><li>http://www.flickr.com/photos/seantubridy/ </li></ul><ul><li>http://www.flickr.com/photos/aasta/ </li></ul><ul><li>http://www.flickr.com/photos/guiniveve/ </li></ul><ul><li>http://flickr.com/photos/annevoi/ </li></ul><ul><li>http://www.flickr.com/photos/chaspope </li></ul><ul><li>http://www.flickr.com/photos/massenpunkt </li></ul><ul><li>http://www.flickr.com/photos/night_heron </li></ul><ul><li>http://www.flickr.com/photos/80336234@N00 </li></ul>
  22. 22. <ul><li>www.acceptancetesting.info </li></ul><ul><li>http://gojko.net </li></ul>
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×