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

PPTX
Php unit for drupal 8
PPTX
Automated php unit testing in drupal 8
PPTX
Jenkins Evolutions - JEEConf 2012
PPTX
In Memory Unit Testing with Apache DbUnit
PDF
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
PDF
Django Rest Framework and React and Redux, Oh My!
PPTX
Spring boot Introduction
PPT
An introduction to maven gradle and sbt
Php unit for drupal 8
Automated php unit testing in drupal 8
Jenkins Evolutions - JEEConf 2012
In Memory Unit Testing with Apache DbUnit
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
Django Rest Framework and React and Redux, Oh My!
Spring boot Introduction
An introduction to maven gradle and sbt

What's hot (20)

PDF
Developing Plug-Ins for NetBeans
PPT
Java build tool_comparison
PDF
Enabling White-Box Reuse in a Pure Composition Language
PDF
Scala and Play with Gradle
PPTX
Apache ant
PDF
Introduction to Apache Ant
PDF
34 using mysql with java
PPTX
Hibernate
PPT
PPTX
Node.js Development with Apache NetBeans
PPTX
Faster java ee builds with gradle [con4921]
PPT
Building Quality with Foundations of Mud
PPT
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
PDF
Gradle Introduction
PDF
prohuddle-utPLSQL v3 - Ultimate unit testing framework for Oracle
PPTX
Spring Boot
PPT
Testing in AngularJS
ODP
Jquery- One slide completing all JQuery
PDF
Play framework productivity formula
PDF
JavaCro'14 - Scala and Java EE 7 Development Experiences – Peter Pilgrim
Developing Plug-Ins for NetBeans
Java build tool_comparison
Enabling White-Box Reuse in a Pure Composition Language
Scala and Play with Gradle
Apache ant
Introduction to Apache Ant
34 using mysql with java
Hibernate
Node.js Development with Apache NetBeans
Faster java ee builds with gradle [con4921]
Building Quality with Foundations of Mud
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
Gradle Introduction
prohuddle-utPLSQL v3 - Ultimate unit testing framework for Oracle
Spring Boot
Testing in AngularJS
Jquery- One slide completing all JQuery
Play framework productivity formula
JavaCro'14 - Scala and Java EE 7 Development Experiences – Peter Pilgrim
Ad

Similar to Java Unit Testing with Unitils (20)

PPTX
Sqladria 2009 SRC
PDF
Javascript ui for rest services
PPT
EJB 3.0 Java Persistence with Oracle TopLink
KEY
Javascript unit testing, yes we can e big
PDF
Dropwizard
ODP
eXo Platform SEA - Play Framework Introduction
PDF
Apache DeltaSpike the CDI toolbox
PDF
Apache DeltaSpike: The CDI Toolbox
PPTX
Advance java session 5
PDF
WebNet Conference 2012 - Designing complex applications using html5 and knock...
PPT
Hibernate
PPTX
Session 24 - JDBC, Intro to Enterprise Java
PPSX
JDBC Part - 2
PPTX
Adding a modern twist to legacy web applications
ODP
Java Code Generation for Productivity
PPTX
Automation - web testing with selenium
PPTX
Introduction to Spring Boot
PPT
Corephpcomponentpresentation 1211425966721657-8
PPT
Core Php Component Presentation
PDF
Symfony2 - from the trenches
Sqladria 2009 SRC
Javascript ui for rest services
EJB 3.0 Java Persistence with Oracle TopLink
Javascript unit testing, yes we can e big
Dropwizard
eXo Platform SEA - Play Framework Introduction
Apache DeltaSpike the CDI toolbox
Apache DeltaSpike: The CDI Toolbox
Advance java session 5
WebNet Conference 2012 - Designing complex applications using html5 and knock...
Hibernate
Session 24 - JDBC, Intro to Enterprise Java
JDBC Part - 2
Adding a modern twist to legacy web applications
Java Code Generation for Productivity
Automation - web testing with selenium
Introduction to Spring Boot
Corephpcomponentpresentation 1211425966721657-8
Core Php Component Presentation
Symfony2 - from the trenches
Ad

More from Mikalai Alimenkou (20)

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

Recently uploaded (20)

PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PPT
Module 1.ppt Iot fundamentals and Architecture
PDF
A contest of sentiment analysis: k-nearest neighbor versus neural network
PPT
What is a Computer? Input Devices /output devices
PDF
A comparative study of natural language inference in Swahili using monolingua...
PPTX
2018-HIPAA-Renewal-Training for executives
PDF
Getting started with AI Agents and Multi-Agent Systems
PDF
Consumable AI The What, Why & How for Small Teams.pdf
PDF
A proposed approach for plagiarism detection in Myanmar Unicode text
PPTX
Final SEM Unit 1 for mit wpu at pune .pptx
PDF
Abstractive summarization using multilingual text-to-text transfer transforme...
PDF
sustainability-14-14877-v2.pddhzftheheeeee
PDF
Convolutional neural network based encoder-decoder for efficient real-time ob...
PPTX
Modernising the Digital Integration Hub
PPTX
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
PDF
Produktkatalog für HOBO Datenlogger, Wetterstationen, Sensoren, Software und ...
PDF
NewMind AI Weekly Chronicles – August ’25 Week III
PDF
Hindi spoken digit analysis for native and non-native speakers
PDF
Architecture types and enterprise applications.pdf
PDF
STKI Israel Market Study 2025 version august
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
Module 1.ppt Iot fundamentals and Architecture
A contest of sentiment analysis: k-nearest neighbor versus neural network
What is a Computer? Input Devices /output devices
A comparative study of natural language inference in Swahili using monolingua...
2018-HIPAA-Renewal-Training for executives
Getting started with AI Agents and Multi-Agent Systems
Consumable AI The What, Why & How for Small Teams.pdf
A proposed approach for plagiarism detection in Myanmar Unicode text
Final SEM Unit 1 for mit wpu at pune .pptx
Abstractive summarization using multilingual text-to-text transfer transforme...
sustainability-14-14877-v2.pddhzftheheeeee
Convolutional neural network based encoder-decoder for efficient real-time ob...
Modernising the Digital Integration Hub
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
Produktkatalog für HOBO Datenlogger, Wetterstationen, Sensoren, Software und ...
NewMind AI Weekly Chronicles – August ’25 Week III
Hindi spoken digit analysis for native and non-native speakers
Architecture types and enterprise applications.pdf
STKI Israel Market Study 2025 version august

Java Unit Testing with Unitils