SlideShare a Scribd company logo
utPLSQL v3
Ultimate Unit Testing framework for Oracle
Jacek Gębal
twitter: @GebalJacek
mail: jgebal@gmail.com
blog: oraclethoughts.com
Principal Data Engineer Developer
@Fidelity Investments - Ireland
co-author of: utPLSQL v3
Plan
● Oracle Database testing tools
● utPLSQL v3
● Rules of unit testing
● Test Driven Development with utPLSQL
● Testing data
● Test run options
● Suites
● utPLSQL - SQL Developer extension
● utPLSQL-cli - running tests from command line
● CI/CD integration
Steven Feuerstein
1999
PLUTO
PL/Unit
ruby-plsql-spec
DBFit
Oracle Database Unit Testing market
Market expectations
The team
● Jacek Gębal
● Pavel Kaplya
● Robert Love
● David Pyke
● Vinicius Avellar
● Samuel Nitsche
● Philipp Salvisberg
Why utPLSQL v3 ? ● free
● open source
● pure PL/SQL
● Tested on 11gR2 - 12cR2
● IDE independent
● database independent
● CI/CD oriented
● modular and extendable
Properties of
Unit Tests
● Fast
● Isolated
● Repeatable
● Self-verifying
● Thorough & Timely
https://github.com/.../F.I.R.S.T-Principles-of-Unit-Testing
https://pragprog.com/.../2012-01/unit-tests-are-first
The Unit Test
also needs to be
● Simple
● Automated
● Testing one behavior
● Living documentation
● Developer’s responsibility
Delivering software that is:
● Safe to change
● Maintainable
● Can be tested and delivered iteratively
Why should I
care ?
What to test in
database ?
● Behavior
○ Logic
○ in / out structure
○ State (?)
● Avoid
○ under-testing
○ over-testing
○ meaningless tests
○ flaky tests
○ aiming for metrics (coverage/test count)
Test Driven Development
● write a test
● make it fail
● keep it simple
● tests are examples
● tests become
documentation
● get to green fast
● take baby steps
● stuck?
undo and start over
● write only enough
code to pass the test
● remove duplication
(in code and tests)
● rename and clean up
● run tests and stay green
● change implementation,
not behavior
● improve structure
in small steps
RED GREEN
REFACTOR
With TDD you get:
● Fast feedback loop
● Visible progress
● Code is tested before it exists
● Accomplishment
with every new test
Test Driven Development
with utPLSQL v3
● suite structure
● annotations
● expectation syntax
● running tests
● failure and error messages
demo
Summary
Annotation syntax:
--%name( parameter[s] )
Example:
--%suite(description)
--%test(description)
Expectation examples:
ut.expect( 1 ).to_( equal( 1 ) );
ut.expect( ‘Chuck’ ).to_equal( ‘Chuck’ );
Running tests:
exec ut.run();
Annotations
Package:
● --%suite(<description>)
● --%suitepath(<path>)
● --%rollback(auto/manual)
● --%disabled
Test procedure:
● --%test(<description>)
● --%throws(<error_No>[,...])
● --%beforetest(<proc_name>)
● --%aftertest(<proc_name>)
● --%rollback(auto/manual)
● --%disabled
Procedure:
● --%beforeall, --%afterall
● --%beforeeach, --%aftereach
Expectations & matchers
● be_null
● be_true
● be_greater_than( expected )
● be_less_than( expected )
● equal( expected )
● be_like( mask [, escape_char] )
ut.expect( actual ).to_( matcher(param[, param...]) );
ut.expect( actual ).not_to( matcher(param[, param...]) );
● be_not_null
● be_false
● be_greater_or_equal( expected )
● be_less_or_equal( expected )
● be_between( lower, upper )
● match( pattern [, modifiers] )
● be_empty ● have_count( count )
Matchers:
Equality rules in tests
ut.expect( 100 ).to_equal( ‘100’ );
ut.expect( ‘abcdef’ ).to_equal( to_clob( ‘abcdef’ ) );
ut.expect( systimestamp ).to_equal( current_timestamp );
ut.expect( sysdate ).to_equal( ‘20-MAR-2018’ );
When it comes to unit testing ...
Data types matter!
Supported data-types
● clob, blob
● timestamp (with (local) timezone)
● interval (day to second / year to month)
● cursor
● object, nested table, varray type
● number (integer)
● varchar2 (char / varchar)
● date
● boolean
Testing data
● data setup / cleanup
● cursor data comparison
● automatic rollback
● selective comparison
demo
--%suite(Demo suite)
--%beforeall
procedure data_setup_before_all;
--%beforeeach
procedure thing_to_do_before_each_test;
--%test(Does a thing)
procedure test_the_thing;
--%test(Does stuff)
--%beforetest(setup_before_stuff)
--%aftertest(cleanup_after_stuff)
procedure test_stuff;
procedure setup_before_stuff;
procedure cleanup_after_stuff;
--%afterall
procedure cleanup_after_all_is_done;
data_setup_before_all
thing_to_do_before_each_test
test_the_thing
thing_to_do_before_each_test
setup_before_stuff
test_stuff
cleanup_after_stuff
cleanup_after_all_is_done
savepoint before_suite
Order of execution
savepoint before_test
rollback to before_suite
rollback to before_test
savepoint before_test
rollback to before_test
& test isolation
Organizing tests
● suites hierarchy with suitepath
● parent, siblings, ancestors
● shared beforeall / afterall
● suites isolation / setup scope
demo
package test_add_room_content as
--%suite(Add content to a room)
--%suitepath(org.utplsql.demo.test_rooms)
package test_remove_rooms_by_name as
--%suite(Remove rooms by name)
--%suitepath(org.utplsql.demo.test_rooms)
package test_rooms as
--%suite
--%suitepath(org.utplsql.demo)
package test_betwnstr as
--%suite(description)
savepoint
rollback to savepoint
Suite hierarchy test run
utplsql
test_betwnstr
test_rooms
test_add_room_content test_remove_rooms_by_name
org
demo
savepoint
rollback to savepoint
savepoint
rollback to savepoint
Test run options
● default options
● single schema
● single package
● single test
● suite
● multiple schema
● specifying reporter
demo
utPLSQL - SQL Developer extension
demo
utplsql-cli
● Windows/Linux/Mac
● real-time reporting
● multi-reporting
● Oracle client independent
● CI/CD oriented
demo
Integration
● CI/CD servers
○ Jenkins
○ TeamCity
○ Travis
○ other...
● Sonar
○ generic test results
○ code coverage
● Coveralls
○ code coverage
demo
utPLSQL v3 recap
● free, open-source, pure PL/SQL
● annotations
● human readable syntax
● data type - aware comparison
● automatic test isolation
● rich selection of matchers
● supports cursors, object types, nested tables
● CI/CD oriented
● code coverage
Resources
Cheat-sheet: https://www.cheatography.com/jgebal/cheat-sheets/utplsql-v3/
Documentation: http://utplsql.org/utPLSQL/
Source code: https://github.com/utPLSQL/utPLSQL
Releases: https://github.com/utPLSQL/utPLSQL/releases
utPLSQL-cli: https://github.com/utPLSQL/utPLSQL-cli/releases
SQLDeveloper-extension: https://github.com/utPLSQL/utPLSQL-SQLDeveloper/releases
Twitter: @utplsql
Demo project: https://github.com/utPLSQL/utPLSQL-demo-project
Sonar results: https://sonarcloud.io/dashboard?id=utPLSQL
Coveralls results: https://coveralls.io/github/utPLSQL/utPLSQL
Travis-CI builds: https://travis-ci.org/utPLSQL/utPLSQL

More Related Content

PDF
Ukoug webinar - testing PLSQL APIs with utPLSQL v3
PDF
POUG2019 - Test your PL/SQL - your database will love you
PPTX
utPLSQL: Unit Testing for Oracle PL/SQL
PPTX
Oracle Unit Testing with utPLSQL
PDF
Test Driven Development for PLSQL with utPLSQL v3
PDF
Unit Testing Oracle PL/SQL Code: utPLSQL, Excel and More
PPTX
Unit Testing
PDF
Workshop unit test
Ukoug webinar - testing PLSQL APIs with utPLSQL v3
POUG2019 - Test your PL/SQL - your database will love you
utPLSQL: Unit Testing for Oracle PL/SQL
Oracle Unit Testing with utPLSQL
Test Driven Development for PLSQL with utPLSQL v3
Unit Testing Oracle PL/SQL Code: utPLSQL, Excel and More
Unit Testing
Workshop unit test

What's hot (20)

PPTX
An Introduction to Unit Testing
PPTX
Unit Testing And Mocking
PPS
Unit Testing
ODP
Unit testing with Qt test
PDF
Unit testing best practices
PPT
Google test training
PPT
Google mock for dummies
PDF
An introduction to unit testing
PDF
An introduction to Google test framework
PDF
C++ Unit Test with Google Testing Framework
PDF
Create an architecture for web test automation
PPTX
Angular Unit Testing
PDF
GMock framework
PPT
Test Automation Framework Designs
PPTX
Kubernetes Selenium Grid
PPTX
Automation Testing
PDF
Test Automation
PPTX
Mocking with Mockito
PDF
IoT Attack Surfaces -- DEFCON 2015
PPTX
Selenium Automation
An Introduction to Unit Testing
Unit Testing And Mocking
Unit Testing
Unit testing with Qt test
Unit testing best practices
Google test training
Google mock for dummies
An introduction to unit testing
An introduction to Google test framework
C++ Unit Test with Google Testing Framework
Create an architecture for web test automation
Angular Unit Testing
GMock framework
Test Automation Framework Designs
Kubernetes Selenium Grid
Automation Testing
Test Automation
Mocking with Mockito
IoT Attack Surfaces -- DEFCON 2015
Selenium Automation
Ad

Similar to prohuddle-utPLSQL v3 - Ultimate unit testing framework for Oracle (20)

PDF
Bgoug 2019.11 test your pl sql - not your patience
PDF
QA Meetup at Signavio (Berlin, 06.06.19)
PDF
Test Driven Development with Sql Server
PDF
Free oracle performance tools
PDF
Developer Tests - Things to Know (Vilnius JUG)
PDF
Q4.11: Getting Started in LAVA
PDF
Presto Testing Tools: Benchto & Tempto (Presto Boston Meetup 10062015)
PDF
Strategy-driven Test Generation with Open Source Frameworks
PPTX
Testing Django APIs
PPTX
Beyond unit tests: Deployment and testing for Hadoop/Spark workflows
PPTX
1.Python_Testing_Using_PyUnit_Pytest.pptx
PPTX
2.Python_Unit _Testing_Using_PyUnit_Pytest.pptx
ODP
NovaProva, a new generation unit test framework for C programs
PDF
Curating Your Cukes by Eric Kessler
PPTX
unittestinginpythonfor-PYDevelopers.pptx
PPTX
Unit testing
PDF
Pl sql office hours data setup and teardown in database testing
PPTX
Introduction to unit testing in python
PDF
Test driven development
PDF
Developers Testing - Girl Code at bloomon
Bgoug 2019.11 test your pl sql - not your patience
QA Meetup at Signavio (Berlin, 06.06.19)
Test Driven Development with Sql Server
Free oracle performance tools
Developer Tests - Things to Know (Vilnius JUG)
Q4.11: Getting Started in LAVA
Presto Testing Tools: Benchto & Tempto (Presto Boston Meetup 10062015)
Strategy-driven Test Generation with Open Source Frameworks
Testing Django APIs
Beyond unit tests: Deployment and testing for Hadoop/Spark workflows
1.Python_Testing_Using_PyUnit_Pytest.pptx
2.Python_Unit _Testing_Using_PyUnit_Pytest.pptx
NovaProva, a new generation unit test framework for C programs
Curating Your Cukes by Eric Kessler
unittestinginpythonfor-PYDevelopers.pptx
Unit testing
Pl sql office hours data setup and teardown in database testing
Introduction to unit testing in python
Test driven development
Developers Testing - Girl Code at bloomon
Ad

Recently uploaded (20)

PPTX
ISO 45001 Occupational Health and Safety Management System
PDF
Nekopoi APK 2025 free lastest update
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PPTX
ManageIQ - Sprint 268 Review - Slide Deck
PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PPT
Introduction Database Management System for Course Database
PDF
Digital Strategies for Manufacturing Companies
PDF
Understanding Forklifts - TECH EHS Solution
PDF
top salesforce developer skills in 2025.pdf
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
ISO 45001 Occupational Health and Safety Management System
Nekopoi APK 2025 free lastest update
How to Migrate SBCGlobal Email to Yahoo Easily
Wondershare Filmora 15 Crack With Activation Key [2025
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Which alternative to Crystal Reports is best for small or large businesses.pdf
ManageIQ - Sprint 268 Review - Slide Deck
Softaken Excel to vCard Converter Software.pdf
VVF-Customer-Presentation2025-Ver1.9.pptx
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Introduction Database Management System for Course Database
Digital Strategies for Manufacturing Companies
Understanding Forklifts - TECH EHS Solution
top salesforce developer skills in 2025.pdf
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
How Creative Agencies Leverage Project Management Software.pdf
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool

prohuddle-utPLSQL v3 - Ultimate unit testing framework for Oracle

  • 1. utPLSQL v3 Ultimate Unit Testing framework for Oracle Jacek Gębal twitter: @GebalJacek mail: jgebal@gmail.com blog: oraclethoughts.com Principal Data Engineer Developer @Fidelity Investments - Ireland co-author of: utPLSQL v3
  • 2. Plan ● Oracle Database testing tools ● utPLSQL v3 ● Rules of unit testing ● Test Driven Development with utPLSQL ● Testing data ● Test run options ● Suites ● utPLSQL - SQL Developer extension ● utPLSQL-cli - running tests from command line ● CI/CD integration
  • 5. The team ● Jacek Gębal ● Pavel Kaplya ● Robert Love ● David Pyke ● Vinicius Avellar ● Samuel Nitsche ● Philipp Salvisberg
  • 6. Why utPLSQL v3 ? ● free ● open source ● pure PL/SQL ● Tested on 11gR2 - 12cR2 ● IDE independent ● database independent ● CI/CD oriented ● modular and extendable
  • 7. Properties of Unit Tests ● Fast ● Isolated ● Repeatable ● Self-verifying ● Thorough & Timely https://github.com/.../F.I.R.S.T-Principles-of-Unit-Testing https://pragprog.com/.../2012-01/unit-tests-are-first
  • 8. The Unit Test also needs to be ● Simple ● Automated ● Testing one behavior ● Living documentation ● Developer’s responsibility
  • 9. Delivering software that is: ● Safe to change ● Maintainable ● Can be tested and delivered iteratively Why should I care ?
  • 10. What to test in database ? ● Behavior ○ Logic ○ in / out structure ○ State (?) ● Avoid ○ under-testing ○ over-testing ○ meaningless tests ○ flaky tests ○ aiming for metrics (coverage/test count)
  • 11. Test Driven Development ● write a test ● make it fail ● keep it simple ● tests are examples ● tests become documentation ● get to green fast ● take baby steps ● stuck? undo and start over ● write only enough code to pass the test ● remove duplication (in code and tests) ● rename and clean up ● run tests and stay green ● change implementation, not behavior ● improve structure in small steps RED GREEN REFACTOR With TDD you get: ● Fast feedback loop ● Visible progress ● Code is tested before it exists ● Accomplishment with every new test
  • 12. Test Driven Development with utPLSQL v3 ● suite structure ● annotations ● expectation syntax ● running tests ● failure and error messages
  • 13. demo
  • 14. Summary Annotation syntax: --%name( parameter[s] ) Example: --%suite(description) --%test(description) Expectation examples: ut.expect( 1 ).to_( equal( 1 ) ); ut.expect( ‘Chuck’ ).to_equal( ‘Chuck’ ); Running tests: exec ut.run();
  • 15. Annotations Package: ● --%suite(<description>) ● --%suitepath(<path>) ● --%rollback(auto/manual) ● --%disabled Test procedure: ● --%test(<description>) ● --%throws(<error_No>[,...]) ● --%beforetest(<proc_name>) ● --%aftertest(<proc_name>) ● --%rollback(auto/manual) ● --%disabled Procedure: ● --%beforeall, --%afterall ● --%beforeeach, --%aftereach
  • 16. Expectations & matchers ● be_null ● be_true ● be_greater_than( expected ) ● be_less_than( expected ) ● equal( expected ) ● be_like( mask [, escape_char] ) ut.expect( actual ).to_( matcher(param[, param...]) ); ut.expect( actual ).not_to( matcher(param[, param...]) ); ● be_not_null ● be_false ● be_greater_or_equal( expected ) ● be_less_or_equal( expected ) ● be_between( lower, upper ) ● match( pattern [, modifiers] ) ● be_empty ● have_count( count ) Matchers:
  • 17. Equality rules in tests ut.expect( 100 ).to_equal( ‘100’ ); ut.expect( ‘abcdef’ ).to_equal( to_clob( ‘abcdef’ ) ); ut.expect( systimestamp ).to_equal( current_timestamp ); ut.expect( sysdate ).to_equal( ‘20-MAR-2018’ ); When it comes to unit testing ... Data types matter!
  • 18. Supported data-types ● clob, blob ● timestamp (with (local) timezone) ● interval (day to second / year to month) ● cursor ● object, nested table, varray type ● number (integer) ● varchar2 (char / varchar) ● date ● boolean
  • 19. Testing data ● data setup / cleanup ● cursor data comparison ● automatic rollback ● selective comparison
  • 20. demo
  • 21. --%suite(Demo suite) --%beforeall procedure data_setup_before_all; --%beforeeach procedure thing_to_do_before_each_test; --%test(Does a thing) procedure test_the_thing; --%test(Does stuff) --%beforetest(setup_before_stuff) --%aftertest(cleanup_after_stuff) procedure test_stuff; procedure setup_before_stuff; procedure cleanup_after_stuff; --%afterall procedure cleanup_after_all_is_done; data_setup_before_all thing_to_do_before_each_test test_the_thing thing_to_do_before_each_test setup_before_stuff test_stuff cleanup_after_stuff cleanup_after_all_is_done savepoint before_suite Order of execution savepoint before_test rollback to before_suite rollback to before_test savepoint before_test rollback to before_test & test isolation
  • 22. Organizing tests ● suites hierarchy with suitepath ● parent, siblings, ancestors ● shared beforeall / afterall ● suites isolation / setup scope
  • 23. demo
  • 24. package test_add_room_content as --%suite(Add content to a room) --%suitepath(org.utplsql.demo.test_rooms) package test_remove_rooms_by_name as --%suite(Remove rooms by name) --%suitepath(org.utplsql.demo.test_rooms) package test_rooms as --%suite --%suitepath(org.utplsql.demo) package test_betwnstr as --%suite(description) savepoint rollback to savepoint Suite hierarchy test run utplsql test_betwnstr test_rooms test_add_room_content test_remove_rooms_by_name org demo savepoint rollback to savepoint savepoint rollback to savepoint
  • 25. Test run options ● default options ● single schema ● single package ● single test ● suite ● multiple schema ● specifying reporter
  • 26. demo
  • 27. utPLSQL - SQL Developer extension
  • 28. demo
  • 29. utplsql-cli ● Windows/Linux/Mac ● real-time reporting ● multi-reporting ● Oracle client independent ● CI/CD oriented
  • 30. demo
  • 31. Integration ● CI/CD servers ○ Jenkins ○ TeamCity ○ Travis ○ other... ● Sonar ○ generic test results ○ code coverage ● Coveralls ○ code coverage
  • 32. demo
  • 33. utPLSQL v3 recap ● free, open-source, pure PL/SQL ● annotations ● human readable syntax ● data type - aware comparison ● automatic test isolation ● rich selection of matchers ● supports cursors, object types, nested tables ● CI/CD oriented ● code coverage
  • 34. Resources Cheat-sheet: https://www.cheatography.com/jgebal/cheat-sheets/utplsql-v3/ Documentation: http://utplsql.org/utPLSQL/ Source code: https://github.com/utPLSQL/utPLSQL Releases: https://github.com/utPLSQL/utPLSQL/releases utPLSQL-cli: https://github.com/utPLSQL/utPLSQL-cli/releases SQLDeveloper-extension: https://github.com/utPLSQL/utPLSQL-SQLDeveloper/releases Twitter: @utplsql Demo project: https://github.com/utPLSQL/utPLSQL-demo-project Sonar results: https://sonarcloud.io/dashboard?id=utPLSQL Coveralls results: https://coveralls.io/github/utPLSQL/utPLSQL Travis-CI builds: https://travis-ci.org/utPLSQL/utPLSQL