SlideShare a Scribd company logo
Java Unit Testing with UnitilsMikalai Alimenkouhttp://xpinjection.com21.05.2011
BackgroundJava Technical Lead/Scrum Master at Zoral Labs6+ years in software development4+ years of working by Agile methodologiesExpert in Agile engineering practicesFounder and coachat XP Injection (http://xpinjection.com)Organizer of Selenium Camp and JEEConf conferences
General IdeaTestNG
Unitils HistorySpring test integrationMulti db supportVarious improvementsUnitils 3.0DbMaintain 2.2Testing guidelinesfrom brainstormSeparate modulesUnitils 2.0Unitils 1.0DbMaintain 2.0DbMaintain separated from UnitilsUnitils RC1
Unitils FactsOpen sourceIntegrates with JUnit and TestNGModular and flexible architectureLots of useful utilities
Modular ArchitectureExisting modulesDatabaseModuleDbUnitModuleHibernateModuleMockModuleEasyMockModuleInjectModuleSpringModuleCreate new or change implementationConfigure only needed modules
Flexible ConfigurationEverything is configurable3 levels of overridden properties
Database TestingMain problemsMocking or real data?JDBC, Hibernate, JPA, …Testing approachesCreate database, clean databaseLocal transactions
Unitils SolutionDatabase maintainerSmall test datasets with DbUnit@Transactional supportSeparate schema per developerCustom DataSource for more control
Database MaintenanceKeep database schema in VCSGreat versioning technique with incremental updatesAbility to disable constraints
Database MaintenanceSupports large number of databasesPrepares sequences and identity columnsMany options for database and data maintenanceGenerate XSD or DTD for DbUnit datasets
DbMaintain Projecthttp://www.dbmaintain.orgSeparated from UnitilsCan be used to automate deployment and upgrade procedureVersion 2.3 in May 2011
DbMaintain Scripts StructureIncremental database updatesCommitted files are unchangeableStrict sequenceSupports repeatable scripts, postprocessing
DbMaintain Scripts StructureRename of scripts and folders is supportedMulti-database and patches supportScript information is stored in special table
DbMaintain ExecutionAnt<updateDatabasescriptLocations="${database.archive}"> 		<database driverClassName="org.hsqldb.jdbcDriver" 				url="jdbc:hsqldb:mem:mydb" userName="admin" password="pwd" 		schemaNames="PUBLIC" /> 	</updateDatabase>Command line/path/to/dbmaintain/bin/dbmaintain.sh update 				path/to/scriptFolderOrArchiveJava codeURL configurationUrl = new File("dbmaintain.properties").toURI().toURL();MainFactorymainFactory = new MainFactory(configurationUrl);DbMaintainerdbMaintainer = createDbMaintainer();dbMaintainer.updateDatabase(false);
DbMaintain CommandscreateScriptArchiveupdateDatabasemarkErrorScriptPerformedmarkErrorScriptRevertedmarkDatabaseAsUpToDatecheckScriptUpdatesclearDatabasecleanDatabasedisableConstraintsupdateSequences
DbUnit IntegrationSmall test datasetsOnly needed fields presentXSD or DTD for XML datasets validation and autocompletion
DbUnit IntegrationGranular datasets on class or test levelFlexible datasets naming policyTest and expected datasetsMultiple datasets support
EasyMock IntegrationTestedObject conceptEasy mocks creation with annotationsCompletely configurable mocksExtended set of parameter conditionsInjection of mocks
Own Mocking Library
Own Mocking LibraryCan be used in parallel with EasyMockMocking style like in MockitoDummy objectsPartial mocks
Spring IntegrationContext loading with cachingDifferent types of Spring bean injectionAbility to override beans by loading multiple contexts
Hibernate IntegrationSpecial test for mapping consistencyEasy to create and inject SessionFactory
JPA IntegrationSupports Hibernate, Toplink, OpenJPAJpaEntityManagerFactory creates EntityManager for each testJPA utilities for injection and mapping validation
Assertion UtilitiesReflection basedFlexible comparisonIgnore types of numbers and collectionsIgnore order in collectionsIgnore propertiesAble to compare only some properties
Assertion UtilitiesSupports object hierarchyGreat differences reportingLenient by default
Unitils FailuresFirst record in DbUnit dataset should have all columns used further
Conditions must be set for all parameters in method when using EasyMock

More Related Content

What's hot (20)

PDF
Developing Plug-Ins for NetBeans
elliando dias
 
PPT
Java build tool_comparison
Manav Prasad
 
PDF
Enabling White-Box Reuse in a Pure Composition Language
elliando dias
 
PDF
Scala and Play with Gradle
Wei Chen
 
PPTX
Apache ant
koniik
 
PDF
Introduction to Apache Ant
Shih-Hsiang Lin
 
PDF
34 using mysql with java
果 果
 
PPTX
Hibernate
Mallikarjuna G D
 
PPT
Ant
Manav Prasad
 
PPTX
Node.js Development with Apache NetBeans
Ryan Cuprak
 
PPTX
Faster java ee builds with gradle [con4921]
Ryan Cuprak
 
PPT
Building Quality with Foundations of Mud
seleniumconf
 
PPT
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
Srijan Technologies
 
PDF
Gradle Introduction
Dmitry Buzdin
 
PDF
prohuddle-utPLSQL v3 - Ultimate unit testing framework for Oracle
Jacek Gebal
 
PPTX
Spring Boot
Jiayun Zhou
 
PPT
Testing in AngularJS
Peter Drinnan
 
ODP
Jquery- One slide completing all JQuery
Knoldus Inc.
 
PDF
Play framework productivity formula
Sorin Chiprian
 
PDF
JavaCro'14 - Scala and Java EE 7 Development Experiences – Peter Pilgrim
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
Developing Plug-Ins for NetBeans
elliando dias
 
Java build tool_comparison
Manav Prasad
 
Enabling White-Box Reuse in a Pure Composition Language
elliando dias
 
Scala and Play with Gradle
Wei Chen
 
Apache ant
koniik
 
Introduction to Apache Ant
Shih-Hsiang Lin
 
34 using mysql with java
果 果
 
Hibernate
Mallikarjuna G D
 
Node.js Development with Apache NetBeans
Ryan Cuprak
 
Faster java ee builds with gradle [con4921]
Ryan Cuprak
 
Building Quality with Foundations of Mud
seleniumconf
 
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
Srijan Technologies
 
Gradle Introduction
Dmitry Buzdin
 
prohuddle-utPLSQL v3 - Ultimate unit testing framework for Oracle
Jacek Gebal
 
Spring Boot
Jiayun Zhou
 
Testing in AngularJS
Peter Drinnan
 
Jquery- One slide completing all JQuery
Knoldus Inc.
 
Play framework productivity formula
Sorin Chiprian
 
JavaCro'14 - Scala and Java EE 7 Development Experiences – Peter Pilgrim
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 

Similar to Java Unit Testing with Unitils (10)

PPT
Unitils
tarkaus
 
PPTX
TDD for DB integration
Mikalai Alimenkou
 
ODP
Presentation Unit Testing process
Bárbara Cabral da Conceição, CTFL
 
ODP
Unit testing: unitils & dbmaintain
nevenfi
 
ODP
DbSetup
fbenault
 
PDF
Teste de Integração com DbUnit e jIntegrity
Washington Botelho
 
PPT
Effective Test Driven Database Development
elliando dias
 
PPTX
java sql hibernate and springsDAKSHAYINI 3BR19EE026.pptx
ZakiyaSultana7
 
PPTX
Le Tour de xUnit
Abdelmonaim Remani
 
PPTX
Bro, manage test data like a pro! [QA Fest 2018]
Mikalai Alimenkou
 
Unitils
tarkaus
 
TDD for DB integration
Mikalai Alimenkou
 
Presentation Unit Testing process
Bárbara Cabral da Conceição, CTFL
 
Unit testing: unitils & dbmaintain
nevenfi
 
DbSetup
fbenault
 
Teste de Integração com DbUnit e jIntegrity
Washington Botelho
 
Effective Test Driven Database Development
elliando dias
 
java sql hibernate and springsDAKSHAYINI 3BR19EE026.pptx
ZakiyaSultana7
 
Le Tour de xUnit
Abdelmonaim Remani
 
Bro, manage test data like a pro! [QA Fest 2018]
Mikalai Alimenkou
 
Ad

More from Mikalai Alimenkou (20)

PPTX
Rise and fall of Story Points. Capacity based planning from the trenches.
Mikalai Alimenkou
 
PPTX
Static analysis tools as the best friend of QA
Mikalai Alimenkou
 
PPTX
Modern CI/CD in the microservices world with Kubernetes
Mikalai Alimenkou
 
PPTX
Saga about distributed business transactions in microservices world
Mikalai Alimenkou
 
PPTX
Effectiveness tips from Kubernetes trenches by Captain Obvious
Mikalai Alimenkou
 
PPTX
Ride the database in JUnit tests with Database Rider
Mikalai Alimenkou
 
PPTX
Wastful waste or why everything is so slow in development
Mikalai Alimenkou
 
PPTX
Hexagonal architecture with Spring Boot
Mikalai Alimenkou
 
PPTX
Wastful waste or why everything is so slow in development
Mikalai Alimenkou
 
PPTX
DevOps checklist or how to understand where is your team in DevOps landscape ...
Mikalai Alimenkou
 
PPTX
DevOps checklist or how to understand where is your team in DevOps landscape
Mikalai Alimenkou
 
PDF
Практические трудности в разработке Медкарты для целой страны
Mikalai Alimenkou
 
PPTX
Hexagonal architecture with Spring Boot [EPAM Java online conference]
Mikalai Alimenkou
 
PPTX
Agile antipatterns: review after 10 years of practice
Mikalai Alimenkou
 
PPTX
Hexagonal architecture with Spring Boot
Mikalai Alimenkou
 
PPTX
Bro, manage test data like a pro!
Mikalai Alimenkou
 
PPTX
Бытовая классификация тестировщиков с точки зрения разработчика
Mikalai Alimenkou
 
PPTX
Code Review tool for personal effectiveness and waste analysis
Mikalai Alimenkou
 
PDF
Funny stories and anti-patterns from DevOps landscape
Mikalai Alimenkou
 
PPTX
Developer + tester = quality++
Mikalai Alimenkou
 
Rise and fall of Story Points. Capacity based planning from the trenches.
Mikalai Alimenkou
 
Static analysis tools as the best friend of QA
Mikalai Alimenkou
 
Modern CI/CD in the microservices world with Kubernetes
Mikalai Alimenkou
 
Saga about distributed business transactions in microservices world
Mikalai Alimenkou
 
Effectiveness tips from Kubernetes trenches by Captain Obvious
Mikalai Alimenkou
 
Ride the database in JUnit tests with Database Rider
Mikalai Alimenkou
 
Wastful waste or why everything is so slow in development
Mikalai Alimenkou
 
Hexagonal architecture with Spring Boot
Mikalai Alimenkou
 
Wastful waste or why everything is so slow in development
Mikalai Alimenkou
 
DevOps checklist or how to understand where is your team in DevOps landscape ...
Mikalai Alimenkou
 
DevOps checklist or how to understand where is your team in DevOps landscape
Mikalai Alimenkou
 
Практические трудности в разработке Медкарты для целой страны
Mikalai Alimenkou
 
Hexagonal architecture with Spring Boot [EPAM Java online conference]
Mikalai Alimenkou
 
Agile antipatterns: review after 10 years of practice
Mikalai Alimenkou
 
Hexagonal architecture with Spring Boot
Mikalai Alimenkou
 
Bro, manage test data like a pro!
Mikalai Alimenkou
 
Бытовая классификация тестировщиков с точки зрения разработчика
Mikalai Alimenkou
 
Code Review tool for personal effectiveness and waste analysis
Mikalai Alimenkou
 
Funny stories and anti-patterns from DevOps landscape
Mikalai Alimenkou
 
Developer + tester = quality++
Mikalai Alimenkou
 
Ad

Recently uploaded (20)

PDF
The Growing Value and Application of FME & GenAI
Safe Software
 
PDF
UiPath Agentic AI ile Akıllı Otomasyonun Yeni Çağı
UiPathCommunity
 
PDF
Hello I'm "AI" Your New _________________
Dr. Tathagat Varma
 
PPTX
Practical Applications of AI in Local Government
OnBoard
 
PDF
ArcGIS Utility Network Migration - The Hunter Water Story
Safe Software
 
PDF
From Chatbot to Destroyer of Endpoints - Can ChatGPT Automate EDR Bypasses (1...
Priyanka Aash
 
PPTX
Paycifi - Programmable Trust_Breakfast_PPTXT
FinTech Belgium
 
PDF
Why aren't you using FME Flow's CPU Time?
Safe Software
 
PDF
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Saikat Basu
 
PDF
Java 25 and Beyond - A Roadmap of Innovations
Ana-Maria Mihalceanu
 
PDF
My Journey from CAD to BIM: A True Underdog Story
Safe Software
 
DOCX
Daily Lesson Log MATATAG ICT TEchnology 8
LOIDAALMAZAN3
 
PPTX
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
 
PDF
5 Things to Consider When Deploying AI in Your Enterprise
Safe Software
 
PPTX
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Poster...
Michele Kryston
 
PPTX
UserCon Belgium: Honey, VMware increased my bill
stijn40
 
PPTX
Smarter Governance with AI: What Every Board Needs to Know
OnBoard
 
PDF
Redefining Work in the Age of AI - What to expect? How to prepare? Why it mat...
Malinda Kapuruge
 
PDF
“Scaling i.MX Applications Processors’ Native Edge AI with Discrete AI Accele...
Edge AI and Vision Alliance
 
PPTX
reInforce 2025 Lightning Talk - Scott Francis.pptx
ScottFrancis51
 
The Growing Value and Application of FME & GenAI
Safe Software
 
UiPath Agentic AI ile Akıllı Otomasyonun Yeni Çağı
UiPathCommunity
 
Hello I'm "AI" Your New _________________
Dr. Tathagat Varma
 
Practical Applications of AI in Local Government
OnBoard
 
ArcGIS Utility Network Migration - The Hunter Water Story
Safe Software
 
From Chatbot to Destroyer of Endpoints - Can ChatGPT Automate EDR Bypasses (1...
Priyanka Aash
 
Paycifi - Programmable Trust_Breakfast_PPTXT
FinTech Belgium
 
Why aren't you using FME Flow's CPU Time?
Safe Software
 
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Saikat Basu
 
Java 25 and Beyond - A Roadmap of Innovations
Ana-Maria Mihalceanu
 
My Journey from CAD to BIM: A True Underdog Story
Safe Software
 
Daily Lesson Log MATATAG ICT TEchnology 8
LOIDAALMAZAN3
 
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
 
5 Things to Consider When Deploying AI in Your Enterprise
Safe Software
 
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Poster...
Michele Kryston
 
UserCon Belgium: Honey, VMware increased my bill
stijn40
 
Smarter Governance with AI: What Every Board Needs to Know
OnBoard
 
Redefining Work in the Age of AI - What to expect? How to prepare? Why it mat...
Malinda Kapuruge
 
“Scaling i.MX Applications Processors’ Native Edge AI with Discrete AI Accele...
Edge AI and Vision Alliance
 
reInforce 2025 Lightning Talk - Scott Francis.pptx
ScottFrancis51
 

Java Unit Testing with Unitils