SlideShare a Scribd company logo
Can you test database layer more 
smart than usual? 
Serhii Kartashov 
December 2012 
SoftServe
Agenda 
What’s a problem? 
How we want to resolve that? 
Are you professional?
Agenda 
What’s a problem? 
How we want to resolve that? 
Are you professional?
Problem 
Task: 
please remove old and didn’t marked data from 
production! 
The problem is this: 
you have a SQL database, some stored procedures, 
and a layer of code sitting between your application 
and the database. How can you put tests in place to 
make sure your code really is reading and writing the 
right data from the database?
What’s the best practice? You need 
[multiple] databases! 
devQA (local) prodQA production 
MySQL 
SQL Oracle 
Aster 
MySQL 
Oracle 
Aster 
MySQL 
Oracle 
Aster
How I wanted to do that? First step: 
initialization test data. 
object file network 
con. 
Prepare the 
data 
SQL commit
First step: create the Test and call API.
How I wanted to do that? First step: 
initialization test data. 
SQL 
con. 
Actual Data 
DB 
Expected Data 
Compare
Agenda 
What’s a problem? 
How we want to resolve that? 
Are you professional?
Ideal schema 
Step 1 Step 2 Step 3 
Initialize call API Actual data 
DB DB DB 
Expected 
data 
Compare 
File 
File
Agenda 
What’s a problem? 
How we want to resolve that? 
Are you professional?
DBUnit Framework
DBUnit Core Components 
• IDatabaseConnection - interface representing a DbUnit 
connection to a DB 
• IDataSet - interface representing a collection of tables 
• DatabaseOperation - abstract class representing an operation 
performed on the database before and after each test. 
Operations: 
• NONE 
• UPDATE 
• INSERT 
• REFRESH 
• DELETE 
• DELETE_ALL 
• TRUNCATE_TABLE 
• CLEAN_INSERT (DELETE_ALL and INSERT)
IDatabaseConnection
IDataSet: database 
DataBase 
analytics_comments 
client_id item_id item_name 
client_id item_id item_name 
200 01 name - #1 
200 02 name - #2 
200 03 name - #3
IDataSet: XML file Initialized 
Expected
Database Operation: setUp()
Simple JUnit test
A bit more
Supported RDBMS 
• OracleDatabase 
• MsSQL 
• MySQL 
• IbmDB2 
• IbmInformix 
• H2 
• HypersonicSQL 
• PostgreSQL 
• SybaseSQL 
• InterBase 
• OpenBase8 
• SapDB/MaxDB 
• Derby 
• FrontBase 
Where is Aster database??? 
NOTE: 
1. latest version of DBUnit framework 
doesn’t support Oracle Schemas… 
2. and very inert community…
Thank you! 
Questions?

More Related Content

ODP
Spring Test DBUnit
PPT
Testing persistence in PHP with DbUnit
PDF
Data access
PPT
7\9 SSIS 2008R2_Training - Script Task
PDF
Dao pattern
KEY
Hibernate Performance Tuning (JEEConf 2012)
PPTX
Test Data Builder Pattern
PPTX
Dao example
Spring Test DBUnit
Testing persistence in PHP with DbUnit
Data access
7\9 SSIS 2008R2_Training - Script Task
Dao pattern
Hibernate Performance Tuning (JEEConf 2012)
Test Data Builder Pattern
Dao example

What's hot (20)

ODP
Unit testing: unitils & dbmaintain
PPTX
Creating data with the test data builder pattern
PPTX
Introduction to jQuery
PPT
java jdbc connection
ODP
Hibernate Developer Reference
PPTX
In Memory Unit Testing with Apache DbUnit
PDF
Database Connection Pane
PDF
Java EE 7 Batch processing in the Real World
PDF
Web applications with Catalyst
PPT
Introduction to Hibernate
PPS
Java Hibernate Programming with Architecture Diagram and Example
PDF
What's new in Django 1.7
PDF
Workload Replay in the Cloud: Secret Weapon for Cloud Migrations
ODP
DbSetup
PPTX
Hibernate in Nutshell
PPTX
Configuring jpa in a Spring application
PDF
Let's discover React and Redux with TypeScript
PDF
React & Redux
KEY
Hibernate performance tuning
PPTX
Adding a modern twist to legacy web applications
Unit testing: unitils & dbmaintain
Creating data with the test data builder pattern
Introduction to jQuery
java jdbc connection
Hibernate Developer Reference
In Memory Unit Testing with Apache DbUnit
Database Connection Pane
Java EE 7 Batch processing in the Real World
Web applications with Catalyst
Introduction to Hibernate
Java Hibernate Programming with Architecture Diagram and Example
What's new in Django 1.7
Workload Replay in the Cloud: Secret Weapon for Cloud Migrations
DbSetup
Hibernate in Nutshell
Configuring jpa in a Spring application
Let's discover React and Redux with TypeScript
React & Redux
Hibernate performance tuning
Adding a modern twist to legacy web applications
Ad

Viewers also liked (20)

PDF
Testing database applications with QuickCheck
PPTX
Designing REST services with Spring MVC
PPTX
Testing Database Changes
DOCX
Database testing
PPT
xUnit Style Database Testing
PPTX
Database testing in postgresql query
PPTX
Software Database and Testing
PPT
Database testing
PPS
Database Testing
PPT
Basic Database Testing
PDF
Database Web Application Usability Testing
PDF
01 software test engineering (manual testing)
PPT
Testing in Agile Projects
PPT
Agile QA presentation
PPTX
Agile tour ncr test360_degree - agile testing on steroids
PDF
Agile Testing
PPTX
Agile Testing: The Role Of The Agile Tester
PPT
Agile Testing Process
PDF
Introduction to Agile software testing
PDF
Agile QA Process
Testing database applications with QuickCheck
Designing REST services with Spring MVC
Testing Database Changes
Database testing
xUnit Style Database Testing
Database testing in postgresql query
Software Database and Testing
Database testing
Database Testing
Basic Database Testing
Database Web Application Usability Testing
01 software test engineering (manual testing)
Testing in Agile Projects
Agile QA presentation
Agile tour ncr test360_degree - agile testing on steroids
Agile Testing
Agile Testing: The Role Of The Agile Tester
Agile Testing Process
Introduction to Agile software testing
Agile QA Process
Ad

Similar to Testing database content with DBUnit. My experience. (20)

PPTX
Bro, manage test data like a pro! [QA Fest 2018]
PDF
Database testing tutorial
PPT
Automated Testing with Databases
PDF
Database Testing: A Detailed Guide
PPTX
Why Back-end is the most important part of the system
PPTX
Database Testing
PDF
SELJE_Database_Unit_Testing_Slides.pdf
PDF
A data driven etl test framework sqlsat madison
PPTX
Database Testing.pptx
PPTX
Database API Viewed as a Mathematical Function, Insights into Testing
PPT
Building a Testable Data Access Layer
PDF
Finding Logic Bugs in Database Management Systems
PDF
Db testing concepts swt
PPTX
Lessons learned from designing a QA Automation for analytics databases (big d...
PDF
The Art of Database Experiments – PostgresConf Silicon Valley 2018 / San Jose
PDF
Nancy CLI. Automated Database Experiments
PPTX
Ride the database in JUnit tests with Database Rider
PDF
Tutorial databasetestingusingsql
PDF
Agile db testing_techniques
PPTX
Automated Testing with Databases
Bro, manage test data like a pro! [QA Fest 2018]
Database testing tutorial
Automated Testing with Databases
Database Testing: A Detailed Guide
Why Back-end is the most important part of the system
Database Testing
SELJE_Database_Unit_Testing_Slides.pdf
A data driven etl test framework sqlsat madison
Database Testing.pptx
Database API Viewed as a Mathematical Function, Insights into Testing
Building a Testable Data Access Layer
Finding Logic Bugs in Database Management Systems
Db testing concepts swt
Lessons learned from designing a QA Automation for analytics databases (big d...
The Art of Database Experiments – PostgresConf Silicon Valley 2018 / San Jose
Nancy CLI. Automated Database Experiments
Ride the database in JUnit tests with Database Rider
Tutorial databasetestingusingsql
Agile db testing_techniques
Automated Testing with Databases

Recently uploaded (20)

PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
cuic standard and advanced reporting.pdf
PPT
Teaching material agriculture food technology
PPTX
Cloud computing and distributed systems.
PDF
KodekX | Application Modernization Development
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
A Presentation on Artificial Intelligence
PPTX
Big Data Technologies - Introduction.pptx
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
Understanding_Digital_Forensics_Presentation.pptx
DOCX
The AUB Centre for AI in Media Proposal.docx
Building Integrated photovoltaic BIPV_UPV.pdf
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
The Rise and Fall of 3GPP – Time for a Sabbatical?
cuic standard and advanced reporting.pdf
Teaching material agriculture food technology
Cloud computing and distributed systems.
KodekX | Application Modernization Development
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
NewMind AI Monthly Chronicles - July 2025
Advanced methodologies resolving dimensionality complications for autism neur...
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
A Presentation on Artificial Intelligence
Big Data Technologies - Introduction.pptx
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Understanding_Digital_Forensics_Presentation.pptx
The AUB Centre for AI in Media Proposal.docx

Testing database content with DBUnit. My experience.

  • 1. Can you test database layer more smart than usual? Serhii Kartashov December 2012 SoftServe
  • 2. Agenda What’s a problem? How we want to resolve that? Are you professional?
  • 3. Agenda What’s a problem? How we want to resolve that? Are you professional?
  • 4. Problem Task: please remove old and didn’t marked data from production! The problem is this: you have a SQL database, some stored procedures, and a layer of code sitting between your application and the database. How can you put tests in place to make sure your code really is reading and writing the right data from the database?
  • 5. What’s the best practice? You need [multiple] databases! devQA (local) prodQA production MySQL SQL Oracle Aster MySQL Oracle Aster MySQL Oracle Aster
  • 6. How I wanted to do that? First step: initialization test data. object file network con. Prepare the data SQL commit
  • 7. First step: create the Test and call API.
  • 8. How I wanted to do that? First step: initialization test data. SQL con. Actual Data DB Expected Data Compare
  • 9. Agenda What’s a problem? How we want to resolve that? Are you professional?
  • 10. Ideal schema Step 1 Step 2 Step 3 Initialize call API Actual data DB DB DB Expected data Compare File File
  • 11. Agenda What’s a problem? How we want to resolve that? Are you professional?
  • 13. DBUnit Core Components • IDatabaseConnection - interface representing a DbUnit connection to a DB • IDataSet - interface representing a collection of tables • DatabaseOperation - abstract class representing an operation performed on the database before and after each test. Operations: • NONE • UPDATE • INSERT • REFRESH • DELETE • DELETE_ALL • TRUNCATE_TABLE • CLEAN_INSERT (DELETE_ALL and INSERT)
  • 15. IDataSet: database DataBase analytics_comments client_id item_id item_name client_id item_id item_name 200 01 name - #1 200 02 name - #2 200 03 name - #3
  • 16. IDataSet: XML file Initialized Expected
  • 20. Supported RDBMS • OracleDatabase • MsSQL • MySQL • IbmDB2 • IbmInformix • H2 • HypersonicSQL • PostgreSQL • SybaseSQL • InterBase • OpenBase8 • SapDB/MaxDB • Derby • FrontBase Where is Aster database??? NOTE: 1. latest version of DBUnit framework doesn’t support Oracle Schemas… 2. and very inert community…