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

What's hot (20)

ODP
Unit testing: unitils & dbmaintain
nevenfi
 
PPTX
Creating data with the test data builder pattern
Alan Parkinson
 
PPTX
Introduction to jQuery
Collaboration Technologies
 
PPT
java jdbc connection
Waheed Warraich
 
ODP
Hibernate Developer Reference
Muthuselvam RS
 
PPTX
In Memory Unit Testing with Apache DbUnit
Mohammad Sabir Khan
 
PDF
Database Connection Pane
William Rutherford
 
PDF
Java EE 7 Batch processing in the Real World
Roberto Cortez
 
PDF
Web applications with Catalyst
svilen.ivanov
 
PPT
Introduction to Hibernate
Krishnakanth Goud
 
PPS
Java Hibernate Programming with Architecture Diagram and Example
kamal kotecha
 
PDF
What's new in Django 1.7
Daniel Roseman
 
PDF
Workload Replay in the Cloud: Secret Weapon for Cloud Migrations
John Sterrett
 
ODP
DbSetup
fbenault
 
PPTX
Hibernate in Nutshell
Onkar Deshpande
 
PPTX
Configuring jpa in a Spring application
Jayasree Perilakkalam
 
PDF
Let's discover React and Redux with TypeScript
Mathieu Savy
 
PDF
React & Redux
Federico Bond
 
KEY
Hibernate performance tuning
Sander Mak (@Sander_Mak)
 
PPTX
Adding a modern twist to legacy web applications
Jeff Durta
 
Unit testing: unitils & dbmaintain
nevenfi
 
Creating data with the test data builder pattern
Alan Parkinson
 
Introduction to jQuery
Collaboration Technologies
 
java jdbc connection
Waheed Warraich
 
Hibernate Developer Reference
Muthuselvam RS
 
In Memory Unit Testing with Apache DbUnit
Mohammad Sabir Khan
 
Database Connection Pane
William Rutherford
 
Java EE 7 Batch processing in the Real World
Roberto Cortez
 
Web applications with Catalyst
svilen.ivanov
 
Introduction to Hibernate
Krishnakanth Goud
 
Java Hibernate Programming with Architecture Diagram and Example
kamal kotecha
 
What's new in Django 1.7
Daniel Roseman
 
Workload Replay in the Cloud: Secret Weapon for Cloud Migrations
John Sterrett
 
DbSetup
fbenault
 
Hibernate in Nutshell
Onkar Deshpande
 
Configuring jpa in a Spring application
Jayasree Perilakkalam
 
Let's discover React and Redux with TypeScript
Mathieu Savy
 
React & Redux
Federico Bond
 
Hibernate performance tuning
Sander Mak (@Sander_Mak)
 
Adding a modern twist to legacy web applications
Jeff Durta
 

Viewers also liked (20)

PDF
Testing database applications with QuickCheck
Laura M. Castro
 
PPTX
Designing REST services with Spring MVC
Serhii Kartashov
 
PPTX
Testing Database Changes
Sazed Monsur
 
DOCX
Database testing
Pesara Swamy
 
PPT
xUnit Style Database Testing
Chris Oldwood
 
PPTX
Database testing in postgresql query
mohammed najim
 
PPTX
Software Database and Testing
QualityAssuranceGroup
 
PPT
Database testing
Hrushikesh Wakhle
 
PPS
Database Testing
Ashvin Fofandi
 
PPT
Basic Database Testing
Kumar S
 
PDF
Database Web Application Usability Testing
Tim Broadwater
 
PDF
01 software test engineering (manual testing)
Siddireddy Balu
 
PPT
Testing in Agile Projects
sriks7
 
PPT
Agile QA presentation
Carl Bruiners
 
PPTX
Agile tour ncr test360_degree - agile testing on steroids
Vipul Gupta
 
PDF
Agile Testing
Naresh Jain
 
PPTX
Agile Testing: The Role Of The Agile Tester
Declan Whelan
 
PPT
Agile Testing Process
Intetics
 
PDF
Introduction to Agile software testing
KMS Technology
 
PDF
Agile QA Process
Anand Bagmar
 
Testing database applications with QuickCheck
Laura M. Castro
 
Designing REST services with Spring MVC
Serhii Kartashov
 
Testing Database Changes
Sazed Monsur
 
Database testing
Pesara Swamy
 
xUnit Style Database Testing
Chris Oldwood
 
Database testing in postgresql query
mohammed najim
 
Software Database and Testing
QualityAssuranceGroup
 
Database testing
Hrushikesh Wakhle
 
Database Testing
Ashvin Fofandi
 
Basic Database Testing
Kumar S
 
Database Web Application Usability Testing
Tim Broadwater
 
01 software test engineering (manual testing)
Siddireddy Balu
 
Testing in Agile Projects
sriks7
 
Agile QA presentation
Carl Bruiners
 
Agile tour ncr test360_degree - agile testing on steroids
Vipul Gupta
 
Agile Testing
Naresh Jain
 
Agile Testing: The Role Of The Agile Tester
Declan Whelan
 
Agile Testing Process
Intetics
 
Introduction to Agile software testing
KMS Technology
 
Agile QA Process
Anand Bagmar
 
Ad

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

PPTX
Bro, manage test data like a pro! [QA Fest 2018]
Mikalai Alimenkou
 
PDF
Database testing tutorial
HarikaReddy115
 
PPT
Automated Testing with Databases
elliando dias
 
PDF
Database Testing: A Detailed Guide
Enov8
 
PPTX
Why Back-end is the most important part of the system
BugRaptors
 
PPTX
Database Testing
Siva Kotilingam Pallikonda
 
PDF
SELJE_Database_Unit_Testing_Slides.pdf
Eric Selje
 
PDF
A data driven etl test framework sqlsat madison
Terry Bunio
 
PPTX
Database Testing.pptx
ssuser88c0fd1
 
PPTX
Database API Viewed as a Mathematical Function, Insights into Testing
Brendan Furey
 
PPT
Building a Testable Data Access Layer
Todd Anglin
 
PDF
Finding Logic Bugs in Database Management Systems
PingCAP
 
PDF
Db testing concepts swt
avr07
 
PPTX
Lessons learned from designing a QA Automation for analytics databases (big d...
Omid Vahdaty
 
PDF
The Art of Database Experiments – PostgresConf Silicon Valley 2018 / San Jose
Nikolay Samokhvalov
 
PDF
Nancy CLI. Automated Database Experiments
Nikolay Samokhvalov
 
PPTX
Ride the database in JUnit tests with Database Rider
Mikalai Alimenkou
 
PDF
Tutorial databasetestingusingsql
Renuka Ballal
 
PDF
Agile db testing_techniques
Tarik Essawi
 
PPTX
Automated Testing with Databases
Stephen Ritchie
 
Bro, manage test data like a pro! [QA Fest 2018]
Mikalai Alimenkou
 
Database testing tutorial
HarikaReddy115
 
Automated Testing with Databases
elliando dias
 
Database Testing: A Detailed Guide
Enov8
 
Why Back-end is the most important part of the system
BugRaptors
 
Database Testing
Siva Kotilingam Pallikonda
 
SELJE_Database_Unit_Testing_Slides.pdf
Eric Selje
 
A data driven etl test framework sqlsat madison
Terry Bunio
 
Database Testing.pptx
ssuser88c0fd1
 
Database API Viewed as a Mathematical Function, Insights into Testing
Brendan Furey
 
Building a Testable Data Access Layer
Todd Anglin
 
Finding Logic Bugs in Database Management Systems
PingCAP
 
Db testing concepts swt
avr07
 
Lessons learned from designing a QA Automation for analytics databases (big d...
Omid Vahdaty
 
The Art of Database Experiments – PostgresConf Silicon Valley 2018 / San Jose
Nikolay Samokhvalov
 
Nancy CLI. Automated Database Experiments
Nikolay Samokhvalov
 
Ride the database in JUnit tests with Database Rider
Mikalai Alimenkou
 
Tutorial databasetestingusingsql
Renuka Ballal
 
Agile db testing_techniques
Tarik Essawi
 
Automated Testing with Databases
Stephen Ritchie
 
Ad

Recently uploaded (20)

PPTX
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Poster...
Michele Kryston
 
PDF
Dev Dives: Accelerating agentic automation with Autopilot for Everyone
UiPathCommunity
 
DOCX
Daily Lesson Log MATATAG ICT TEchnology 8
LOIDAALMAZAN3
 
PDF
Plugging AI into everything: Model Context Protocol Simplified.pdf
Abati Adewale
 
PPTX
The birth and death of Stars - earth and life science
rizellemarieastrolo
 
PDF
DoS Attack vs DDoS Attack_ The Silent Wars of the Internet.pdf
CyberPro Magazine
 
PDF
GDG Cloud Southlake #44: Eyal Bukchin: Tightening the Kubernetes Feedback Loo...
James Anderson
 
PPTX
Smart Factory Monitoring IIoT in Machine and Production Operations.pptx
Rejig Digital
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PPTX
Enabling the Digital Artisan – keynote at ICOCI 2025
Alan Dix
 
PPSX
Usergroup - OutSystems Architecture.ppsx
Kurt Vandevelde
 
PDF
Understanding AI Optimization AIO, LLMO, and GEO
CoDigital
 
PPTX
Paycifi - Programmable Trust_Breakfast_PPTXT
FinTech Belgium
 
PPTX
Practical Applications of AI in Local Government
OnBoard
 
PDF
Kubernetes - Architecture & Components.pdf
geethak285
 
PDF
“Scaling i.MX Applications Processors’ Native Edge AI with Discrete AI Accele...
Edge AI and Vision Alliance
 
PPTX
Mastering Authorization: Integrating Authentication and Authorization Data in...
Hitachi, Ltd. OSS Solution Center.
 
PPTX
2025 HackRedCon Cyber Career Paths.pptx Scott Stanton
Scott Stanton
 
PDF
Pipeline Industry IoT - Real Time Data Monitoring
Safe Software
 
PDF
Bridging CAD, IBM TRIRIGA & GIS with FME: The Portland Public Schools Case
Safe Software
 
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Poster...
Michele Kryston
 
Dev Dives: Accelerating agentic automation with Autopilot for Everyone
UiPathCommunity
 
Daily Lesson Log MATATAG ICT TEchnology 8
LOIDAALMAZAN3
 
Plugging AI into everything: Model Context Protocol Simplified.pdf
Abati Adewale
 
The birth and death of Stars - earth and life science
rizellemarieastrolo
 
DoS Attack vs DDoS Attack_ The Silent Wars of the Internet.pdf
CyberPro Magazine
 
GDG Cloud Southlake #44: Eyal Bukchin: Tightening the Kubernetes Feedback Loo...
James Anderson
 
Smart Factory Monitoring IIoT in Machine and Production Operations.pptx
Rejig Digital
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
Enabling the Digital Artisan – keynote at ICOCI 2025
Alan Dix
 
Usergroup - OutSystems Architecture.ppsx
Kurt Vandevelde
 
Understanding AI Optimization AIO, LLMO, and GEO
CoDigital
 
Paycifi - Programmable Trust_Breakfast_PPTXT
FinTech Belgium
 
Practical Applications of AI in Local Government
OnBoard
 
Kubernetes - Architecture & Components.pdf
geethak285
 
“Scaling i.MX Applications Processors’ Native Edge AI with Discrete AI Accele...
Edge AI and Vision Alliance
 
Mastering Authorization: Integrating Authentication and Authorization Data in...
Hitachi, Ltd. OSS Solution Center.
 
2025 HackRedCon Cyber Career Paths.pptx Scott Stanton
Scott Stanton
 
Pipeline Industry IoT - Real Time Data Monitoring
Safe Software
 
Bridging CAD, IBM TRIRIGA & GIS with FME: The Portland Public Schools Case
Safe Software
 

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…