slides

22
Effective Test Driven Database Development Gojko Adzic http://gojko.net [email protected] twitter.com/gojkoadzic

Upload: tess98

Post on 12-Dec-2014

264 views

Category:

Documents


0 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Slides

Effective Test Driven Database Development

Gojko Adzichttp://gojko.net

[email protected]/gojkoadzic

Page 2: Slides

Database somehow always sticks out

Page 3: Slides

Lots of teams struggle with Database testing...

Bad tools Inherently hard to test Changes are persistent Attitude of DB Specialists

Page 4: Slides

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

Page 5: Slides

DB management

Dedicated instances for developers are best One development DB can also work ok Build + n*integrations must always be separate

Page 6: Slides

Don't count on the DB being empty

Tests will be much more effective if they can ignore trash

Page 7: Slides

Generate the glue code and bring the two worlds closer together

Page 8: Slides

Don't fight against database features, use them!

Run tests in transactions!

Page 9: Slides

Isolate non-transactional tests and run them overnight

Page 10: Slides

Do not depend on the order of test execution

Page 11: Slides

Prepare everything you need for an isolated test

Page 12: Slides

Prepare everything you need...

Known state of small development databases Link to files Trash and restore DB

Start with a clean DB and Load data with DbUnit

Set up data for a specific test and roll back later Ideally don't suppose that the DB is empty

Page 13: Slides

ORM is not magic!

Page 14: Slides

DBFIT: Test Driven DB Development Made Easy

FIT+FitNesse+DB Fixtures

http://sourceforge.net/projects/dbfithttp://fitnesse.info/dbfit

Page 15: Slides

Why DbFit?

Manipulate data in a relational model Provides all the plumbing

Transaction management Smart features based on meta-data Parameter mapping “wizards” for regression tests

Because it runs inside FitNesse, already integrated with a lot of other tools/libraries

Page 16: Slides

Use DbFit to:

Write and execute DB Unit tests Prepare/verify Java or .NET integration tests

.NET: Sql Server, Oracle, (DB2) Java: Mysql, Oracle, (DB2, SQL Server, Derby)

Page 17: Slides

Simple commands

Execute procedure Query Execute Insert Update

Page 18: Slides

FitNesse symbols directly mapped to bind variables

Retrieve auto-generated keys and use them directly

<< and >> available in Java as well Already mapped to bind variables

Page 19: Slides

Advanced features

Inspect queries, tables or procs to automatically generate test tables and regression tests

Store and compare queries Standalone mode for full control

Page 20: Slides

DbFit 2.0

Upcoming release in April Support for command timeouts Better architecture, more flexible for different test

runners Integration with Trinidad Support for Db2, Derby, HSQL

Page 21: Slides

Image credits

http://www.flickr.com/photos/seantubridy/ http://www.flickr.com/photos/aasta/ http://www.flickr.com/photos/guiniveve/ http://flickr.com/photos/annevoi/ http://www.flickr.com/photos/chaspope http://www.flickr.com/photos/massenpunkt http://www.flickr.com/photos/night_heron http://www.flickr.com/photos/80336234@N00

Page 22: Slides

www.acceptancetesting.infohttp://gojko.net