Effective Test Driven Database Development Gojko Adzic

Slides:



Advertisements
Similar presentations
Connecting to Databases. connecting to DB DB server typically a standalone application Server runs on localhost for smaller sites –i.e. Same machine as.
Advertisements

Connecting to Databases. relational databases tables and relations accessed using SQL database -specific functionality –transaction processing commit.
Effective Test Driven Database Development Gojko Adzic twitter.com/gojkoadzic.
Moving Data Lesson 23. Skills Matrix Moving Data When populating tables by inserting data, you will discover that data can come from various sources.
SLIM and the future of FitNesse Gojko Adzic
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 13 Introduction to SQL Programming Techniques.
1 JDBC Java Database Connectivity. 2 c.pdf
Fundamentals, Design, and Implementation, 9/e Chapter 11 Managing Databases with SQL Server 2000.
11 3 / 12 CHAPTER Databases MIS105 Lec14 Irfan Ahmed Ilyas.
Session-01. Hibernate Framework ? Why we use Hibernate ?
DAT702.  Standard Query Language  Ability to access and manipulate databases ◦ Retrieve data ◦ Insert, delete, update records ◦ Create and set permissions.
Week 5 – Chap. 5 Data Transfer DBAs often must transfer data to and from text files, Excel spreadsheets, Access, Oracle or other SQL Server databases This.
Unit Testing Tips and Tricks: Database Interaction Louis Thomas.
DB Audit Expert v1.1 for Oracle Copyright © SoftTree Technologies, Inc. This presentation is for DB Audit Expert for Oracle version 1.1 which.
Object Oriented Databases by Adam Stevenson. Object Databases Became commercially popular in mid 1990’s Became commercially popular in mid 1990’s You.
Advance Computer Programming Java Database Connectivity (JDBC) – In order to connect a Java application to a database, you need to use a JDBC driver. –
CSCI 6962: Server-side Design and Programming
1 Web Based Programming Section 6 James King 12 August 2003.
Agenda Journalling More Embedded SQL. Journalling.
Database Design for DNN Developers Sebastian Leupold.
Software Engineering 2003 Jyrki Nummenmaa 1 CASE Tools CASE = Computer-Aided Software Engineering A set of tools to (optimally) assist in each.
1 Overview of Databases. 2 Content Databases Example: Access Structure Query language (SQL)
NHibernate in Action Web Seminar at UMLChina By Pierre Henri Kuaté 2008/08/27
How to Test Data Acces Code or Rube Goldberg:Software Developer.
The protection of the DB against intentional or unintentional threats using computer-based or non- computer-based controls. Database Security – Part 2.
ALMA Integrated Computing Team Coordination & Planning Meeting #1 Santiago, April 2013 Relational APDM & Relational ASDM models effort done in online.
IBM DB2 UD & XML Extender IBM DB2 UD & XML Extender AstroGrid Project Registry Group Pedro Contreras 14 August 2003.
IT 456 Seminar 5 Dr Jeffrey A Robinson. Overview of Course Week 1 – Introduction Week 2 – Installation of SQL and management Tools Week 3 - Creating and.
Object Oriented Analysis and Design 1 Chapter 7 Database Design  UML Specification for Data Modeling  The Relational Data Model and Object Model  Persistence.
Stored procedures1 Stored procedures and functions Procedures and functions stored in the database.
Effective Test Driven Database Development Gojko Adzic
Database Design and Management CPTG /23/2015Chapter 12 of 38 Functions of a Database Store data Store data School: student records, class schedules,
Andrew S. Budarevsky Adaptive Application Data Management Overview.
Hibernate Persistence. What is Persistence Persist data to database or other storage.  In OO world, persistence means persist object to external storage.
Hibernate 3.0. What is Hibernate Hibernate is a free, open source Java package that makes it easy to work with relational databases. Hibernate makes it.
Stored Procedure. Objective At the end of the session you will be able to know :  What are Stored Procedures?  Create a Stored Procedure  Execute a.
Copyright  Oracle Corporation, All rights reserved. 7 Accessing a Database Using SQLJ.
BIS Database Systems School of Management, Business Information Systems, Assumption University A.Thanop Somprasong Chapter # 8 Advanced SQL.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Data Driven Designs 99% of enterprise applications operate on database data or at least interface databases. Most common DBMS are Microsoft SQL Server,
1. When things go wrong: how to find SQL error Sveta Smirnova Principle Technical Support Engineer, Oracle.
JPA / HIBERNATE CSCI 6370 Nilayan Bhattacharya Sanket Sable.
Fighting the monster Agile development on top of a legacy database Gojko Adzic XpDay 2007 – London.
Course FAQ’s I do not have any knowledge on SQL concepts or Database Testing. Will this course helps me to get through all the concepts? What kind of.
CS453: Databases and State in Web Applications (Part 2) Prof. Tom Horton.
Topic : Hibernate 1 Kaster Nurmukan. An ORM tool The problem fixed by ORM Advantage Hibernate Hibernate Basic –Hibernate sessionFactory –Hibernate Session.
1 MSTE Visual SourceSafe For more information, see:
Persistence – Iteration 4 Vancouver Bootcamp Aaron Zeckoski
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Introduction to Data Access with Spring.
Topic : Hibernate 1 Kaster Nurmukan. An ORM tool Used in data layer of applications Implements JPA.
Fundamentals of MyBATIS
SQL Query Analyzer. Graphical tool that allows you to:  Create queries and other SQL scripts and execute them against SQL Server databases. (Query window)
Text TCS INTERNAL Oracle PL/SQL – Introduction. TCS INTERNAL PL SQL Introduction PLSQL means Procedural Language extension of SQL. PLSQL is a database.
Confidencial - TRACASA Automatize test [e- Reporting]
1 JDBC – Java Database Connectivity CS , Spring 2010.
Introduction to ORM Hibernate Hibernate vs JDBC. May 12, 2011 INTRODUCTION TO ORM ORM is a programming technique for converting data between relational.
CS 440 Database Management Systems Stored procedures & OR mapping 1.
By Durga Dasari. DbFit - DB Unit and Integration test tool  Test-driven database development. Write readable, easy- to-maintain unit and integration.
Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe.
1. Writing a Java program to connect to SQL Server 2008 and Create a table Populate the table (insert data) Perform queries to retrieve information from.
New Technology: Why, What ,How
ODBC, OCCI and JDBC overview
JDBC – Java Database Connectivity
Web Technologies IT230 Dr Mohamed Habib.
Persistence – Iteration 4 Vancouver Bootcamp
ADO.NET Entity Framework
PL/SQL Scripting in Oracle:
Jeff Webb Maria Baron Chris Hundersmarck
Developing and testing enterprise Java applications
Chapter 11 Managing Databases with SQL Server 2000
Presentation transcript:

Effective Test Driven Database Development Gojko Adzic

Database somehow always sticks out

Lots of teams struggle with Database testing... Bad tools Inherently hard to test O/R Mismatch Changes are persistent Attitude of DB Specialists

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

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

Don't count on the DB being empty Tests will be much more effective if they can ignore trash

Generate the glue code and bring the two worlds closer together

Don't fight against database features, use them! Run tests in transactions!

...Spring, Hibernate, FitNesse... Declarative transactions, ORM controls the database... So change the test runner and use the automation to your advantage... !define TEST_RUNNER {test.RollbackServer}

...Spring, Hibernate, FitNesse... public void process() { ApplicationContext ctx = new FileSystemXmlApplicationContext("lib/test.xml"); RollbackBean rollbackProcessingBean = (RollbackBean) ctx.getBean("rollback"); try { while ((size = FitProtocol.readSize(socketReader)) != 0) { try { rollbackProcessingBean.process( new DocumentRunner(size)); } catch (RollbackNow rn) { print("rolling back now" + "\n"); } } catch (Exception e) { exception(e); }

...Spring, Hibernate, FitNesse public class RollbackNow extends RuntimeException { } public class public void process(Runnable r){ r.run(); throw new RollbackNow(); }

Isolate non-transactional tests and run them overnight

Do not depend on the order of test execution

Prepare everything you need for an isolated test

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

ORM is not magic!

DBFIT: Test Driven DB Development Made Easy FIT+FitNesse+DB Fixtures

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

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)‏

Simple commands Execute procedure Query Execute Insert Update

FitNesse symbols directly mapped to bind variables Retrieve auto-generated keys and use them directly > available in Java as well Already mapped to bind variables

Advanced features Inspect queries, tables or procs to automatically generate test tables and regression tests Store and compare queries Standalone mode for full control

Image credits /

Q & A... or just bug me later   