SlideShare ist ein Scribd-Unternehmen logo
1 von 17
Oracle Unit Testing with
utPLSQL
Brendan Furey, October 2015
http://aprogrammerwrites.eu/
Agenda
Manual vs Automated Unit Testing, and Agile (6 slides)
utPLSQL vs Gherkin (2 slides)
Working with utPLSQL (5 slides)
utPLSQL Examples (2 slides)
Oracle Unit Testing with utPLSQL 2Brendan Furey, 2015
Manual vs Automated Unit Testing
Unit testing on database is mostly manual up to now
utPLSQL inspired by xUnit testing
Automated unit testing on the database has additional challenges compared
with Java unit testing for example
Database developers express concerns about cost of automation
Creator of utPLSQL admits he does not use it himself
Checklist Driven Development: TDD on the cheap
 "Doing full-blown test driven development (TDD) simply is not going to happen
widely in the Oracle database programming world."
Oracle Unit Testing with utPLSQL 3Brendan Furey, 2015
Cost of Automated Testing
Oracle Unit Testing with utPLSQL 4Brendan Furey, 2015
Agile Changes the Equation
Agile and TDD with ideas of smaller, more frequent changes
Manual testing now too expensive
Automation therefore required
Overall cost may be smaller with automation
Continuous Integration / Delivery changes everything!
utPLSQL was ahead of its time initially (c.15 years ago)
Oracle Unit Testing with utPLSQL 5Brendan Furey, 2015
Example: Feature Cloning with Manual Testing
New feature similar to an existing one (second version of web service maybe)
Manual regression testing too costly, so refactoring rarely happens
Copy and modify, end up with code duplication, larger code base
Code becomes larger and less modular as time passes
FDD - Fear Driven Development
Oracle Unit Testing with utPLSQL 6Brendan Furey, 2015
Example: Feature Cloning with Automated Testing
 Refactor to reduce new code base, and re-use base and unit test code
 Automated regression testing gives confidence to refactor safely
 Code is continuously refined and improved
 Less technical debt
Oracle Unit Testing with utPLSQL 7Brendan Furey, 2015
Testing Cycle: Pattern vs Antipattern
Diagrams from software testing ice-cream cone
Pyramid Ideal Pattern
• Consider testing approaches with these in mind
Icecream Cone Antipattern
Oracle Unit Testing with utPLSQL 8Brendan Furey, 2015
utPLSQL vs Gherkin 1: Gherkin
 Some support for Cucumber and other Gherkin methods, but some
opposition too:
 Please don't use Cucumber
 TDD: Where Did It All Go Wrong?
 Driving motivation may be, as Ian Cooper suggests, due to poor
understanding of TDD
 Notably, focusing on implementation details, not behaviours
 Defining all tests up front with QA, less iterative
 Going out to Java problematic
 May not be very agile?
 Acceptance testing is generally less rigorous than good unit testing
Oracle Unit Testing with utPLSQL 9Brendan Furey, 2015
utPLSQL vs Gherkin 2: utPLSQL
 Processing in base code is of same nature as that of unit testing
code, hence well-suited to database language PL/SQL
 Developer can start with a single test
 Make it work
 Add additional tests and make them work iteratively
 Tests are exclusively behavioural, eliminating need for repeated unit
testing up the pyramid
 More of a TDD approach
 QA will focus on integration tests and avoid unit testing
 Currently QA tend to do unit testing after developers have done theirs
 Symptom of icecream cone antipattern
 QA will validate the development unit tests
Oracle Unit Testing with utPLSQL 10Brendan Furey, 2015
Working with utPLSQL 1: Home Page
utPLSQL Home Page
Steve Feuerstein's Recommendations for unit testing PL/SQL
programs
"utPLSQL is free and gives you total control over your test
code. But that's mostly because you have to write all the test
code"
"If you are allergic to UI-based testing and/or worry about
being constrained by an IDE's feature set (in other words, you
are a command line fanatic), utPLSQL offers a powerful
alternative."
Oracle Unit Testing with utPLSQL 11Brendan Furey, 2015
Working with utPLSQL 2: Structure
 CREATE OR REPLACE PACKAGE ut_package IS
 PROCEDURE ut_setup;
 PROCEDURE ut_teardown;

 PROCEDURE ut_proc;
 END ut_package;
 Think in design patterns
 One web service procedure may be based on the code for an earlier one
 Use similar coding strategies
 Generic array types can help here
 Modularise just as with base code
 Behaviours only tested, no implementation tests
 Large set of ‘assert’ procedures: may be simpler to just cast to strings and assert string
equality
Oracle Unit Testing with utPLSQL 12Brendan Furey, 2015
Working with utPLSQL 3: Improving the Output
Output format not great, but use a wrapper assert procedure
 Can group tests by category such as normal/edge/exception etc.
 Tabular output of expected vs actuals
 Count tests and failures by group
Also summarise by suite
Unit tests succeed or fail, but:
 Can add useful information, such as code timings (I have small
footprint code timer)
 May help to diagnose a sudden performance problem
Oracle Unit Testing with utPLSQL 13Brendan Furey, 2015
Working with utPLSQL 4: Coding Strategies 1 – data
structures etc.
Drive by data structures rather than case by case in program
logic
Use arrays for test data setup, for calling parameters and for
expected results
Use arrays to store meaningful test descriptions
Concatenate fields in a record to reduce number of assertions
Use utility procedures to transform a range to a range category
for assertion, eg NOW = 'in last ten minutes', PAST = 'earlier
than 10 minutes ago'
Use generic arrays rather than creating new record or object
types for each test case
Oracle Unit Testing with utPLSQL 14Brendan Furey, 2015
Working with utPLSQL 5: Coding Strategies 2 - DML
Use special DML APIs for the test data
Parametrise important fields
Use dummy values for other mandatory fields for
simplicity to avoid passing parameters; maybe index-
suffix them
Ignore non-mandatory fields that don't figure in the
testing
May be best to keep simple, and avoid over-sharing
Oracle Unit Testing with utPLSQL 15Brendan Furey, 2015
utPLSQL Example 1: Simple Table API
API to merge reference data into a table
Runs via suite (although only 1 test set in suite)
Oracle Unit Testing with utPLSQL 16Brendan Furey, 2015
utPLSQL Example 2: Web Service Procedure with
Batch Denormalisation
 Batch job runs to pre-populate a table for performance reasons
 Test records for each type of driving entity
 Test each outer-join by including record with missing join
 Check output table record values
 Check output table record counts for the input test set
 Web service procedure reads the table and outputs a reference
cursor
 Input is an array of records
 Array of input arrays for all combinations of inputs
 Test program calls procedure for each input, then reads the output cursor into
an array
 Again test counts and record values against expected value arrays
Oracle Unit Testing with utPLSQL 17Brendan Furey, 2015

Weitere ähnliche Inhalte

Was ist angesagt?

Using runbot to test all your developments automatically
Using runbot to test all your developments automaticallyUsing runbot to test all your developments automatically
Using runbot to test all your developments automaticallyOdoo
 
Session 01 - Introduction to UFT and Features - Slides
Session 01 - Introduction to UFT and Features - SlidesSession 01 - Introduction to UFT and Features - Slides
Session 01 - Introduction to UFT and Features - Slidesrajaselv
 
Turbocharge SQL Performance in PL/SQL with Bulk Processing
Turbocharge SQL Performance in PL/SQL with Bulk ProcessingTurbocharge SQL Performance in PL/SQL with Bulk Processing
Turbocharge SQL Performance in PL/SQL with Bulk ProcessingSteven Feuerstein
 
Introduction to Unified Functional Testing 12 (UFT)
Introduction to Unified Functional Testing 12 (UFT)Introduction to Unified Functional Testing 12 (UFT)
Introduction to Unified Functional Testing 12 (UFT)Archana Krushnan
 
Why to choose HP UFT: Automation testing tool
Why to choose HP UFT: Automation testing toolWhy to choose HP UFT: Automation testing tool
Why to choose HP UFT: Automation testing toolBugRaptors
 
JShell: An Interactive Shell for the Java Platform
JShell: An Interactive Shell for the Java PlatformJShell: An Interactive Shell for the Java Platform
JShell: An Interactive Shell for the Java PlatformJavaDayUA
 
Test Automation Strategy
Test Automation StrategyTest Automation Strategy
Test Automation StrategyMartin Ruddy
 
ISTQB, ISEB Lecture Notes- 2
ISTQB, ISEB Lecture Notes- 2ISTQB, ISEB Lecture Notes- 2
ISTQB, ISEB Lecture Notes- 2onsoftwaretest
 
Less05 storage
Less05 storageLess05 storage
Less05 storageImran Ali
 
Unit Testing Concepts and Best Practices
Unit Testing Concepts and Best PracticesUnit Testing Concepts and Best Practices
Unit Testing Concepts and Best PracticesDerek Smith
 
Oracle R12 EBS Performance Tuning
Oracle R12 EBS Performance TuningOracle R12 EBS Performance Tuning
Oracle R12 EBS Performance TuningScott Jenner
 
Test Process Improvement with TPI NEXT - what the model does not tell you but...
Test Process Improvement with TPI NEXT - what the model does not tell you but...Test Process Improvement with TPI NEXT - what the model does not tell you but...
Test Process Improvement with TPI NEXT - what the model does not tell you but...SQALab
 
오픈 스펙을 대상으로 한 테스트설계사례
오픈 스펙을 대상으로 한 테스트설계사례오픈 스펙을 대상으로 한 테스트설계사례
오픈 스펙을 대상으로 한 테스트설계사례SangIn Choung
 
API Automation Testing Using RestAssured+Cucumber
API Automation Testing Using RestAssured+CucumberAPI Automation Testing Using RestAssured+Cucumber
API Automation Testing Using RestAssured+CucumberKnoldus Inc.
 
Space Camp June 2022 - API First.pdf
Space Camp June 2022 - API First.pdfSpace Camp June 2022 - API First.pdf
Space Camp June 2022 - API First.pdfPostman
 
Oracle Database Performance Tuning Basics
Oracle Database Performance Tuning BasicsOracle Database Performance Tuning Basics
Oracle Database Performance Tuning Basicsnitin anjankar
 
ATDD Using Robot Framework
ATDD Using Robot FrameworkATDD Using Robot Framework
ATDD Using Robot FrameworkPekka Klärck
 
Unit Testing And Mocking
Unit Testing And MockingUnit Testing And Mocking
Unit Testing And MockingJoe Wilson
 

Was ist angesagt? (20)

Using runbot to test all your developments automatically
Using runbot to test all your developments automaticallyUsing runbot to test all your developments automatically
Using runbot to test all your developments automatically
 
Session 01 - Introduction to UFT and Features - Slides
Session 01 - Introduction to UFT and Features - SlidesSession 01 - Introduction to UFT and Features - Slides
Session 01 - Introduction to UFT and Features - Slides
 
Turbocharge SQL Performance in PL/SQL with Bulk Processing
Turbocharge SQL Performance in PL/SQL with Bulk ProcessingTurbocharge SQL Performance in PL/SQL with Bulk Processing
Turbocharge SQL Performance in PL/SQL with Bulk Processing
 
Test NG Framework Complete Walk Through
Test NG Framework Complete Walk ThroughTest NG Framework Complete Walk Through
Test NG Framework Complete Walk Through
 
Introduction to Unified Functional Testing 12 (UFT)
Introduction to Unified Functional Testing 12 (UFT)Introduction to Unified Functional Testing 12 (UFT)
Introduction to Unified Functional Testing 12 (UFT)
 
Why to choose HP UFT: Automation testing tool
Why to choose HP UFT: Automation testing toolWhy to choose HP UFT: Automation testing tool
Why to choose HP UFT: Automation testing tool
 
JShell: An Interactive Shell for the Java Platform
JShell: An Interactive Shell for the Java PlatformJShell: An Interactive Shell for the Java Platform
JShell: An Interactive Shell for the Java Platform
 
Test Automation Strategy
Test Automation StrategyTest Automation Strategy
Test Automation Strategy
 
ISTQB, ISEB Lecture Notes- 2
ISTQB, ISEB Lecture Notes- 2ISTQB, ISEB Lecture Notes- 2
ISTQB, ISEB Lecture Notes- 2
 
Less05 storage
Less05 storageLess05 storage
Less05 storage
 
Unit Testing Concepts and Best Practices
Unit Testing Concepts and Best PracticesUnit Testing Concepts and Best Practices
Unit Testing Concepts and Best Practices
 
Oracle R12 EBS Performance Tuning
Oracle R12 EBS Performance TuningOracle R12 EBS Performance Tuning
Oracle R12 EBS Performance Tuning
 
Test Process Improvement with TPI NEXT - what the model does not tell you but...
Test Process Improvement with TPI NEXT - what the model does not tell you but...Test Process Improvement with TPI NEXT - what the model does not tell you but...
Test Process Improvement with TPI NEXT - what the model does not tell you but...
 
오픈 스펙을 대상으로 한 테스트설계사례
오픈 스펙을 대상으로 한 테스트설계사례오픈 스펙을 대상으로 한 테스트설계사례
오픈 스펙을 대상으로 한 테스트설계사례
 
Istqb lesson 1
Istqb lesson 1Istqb lesson 1
Istqb lesson 1
 
API Automation Testing Using RestAssured+Cucumber
API Automation Testing Using RestAssured+CucumberAPI Automation Testing Using RestAssured+Cucumber
API Automation Testing Using RestAssured+Cucumber
 
Space Camp June 2022 - API First.pdf
Space Camp June 2022 - API First.pdfSpace Camp June 2022 - API First.pdf
Space Camp June 2022 - API First.pdf
 
Oracle Database Performance Tuning Basics
Oracle Database Performance Tuning BasicsOracle Database Performance Tuning Basics
Oracle Database Performance Tuning Basics
 
ATDD Using Robot Framework
ATDD Using Robot FrameworkATDD Using Robot Framework
ATDD Using Robot Framework
 
Unit Testing And Mocking
Unit Testing And MockingUnit Testing And Mocking
Unit Testing And Mocking
 

Ähnlich wie Oracle Unit Testing with utPLSQL

Test driven development and unit testing with examples in C++
Test driven development and unit testing with examples in C++Test driven development and unit testing with examples in C++
Test driven development and unit testing with examples in C++Hong Le Van
 
JUnit- A Unit Testing Framework
JUnit- A Unit Testing FrameworkJUnit- A Unit Testing Framework
JUnit- A Unit Testing FrameworkOnkar Deshpande
 
Test automation principles, terminologies and implementations
Test automation principles, terminologies and implementationsTest automation principles, terminologies and implementations
Test automation principles, terminologies and implementationsSteven Li
 
May 2021 Spark Testing ... or how to farm reputation on StackOverflow
May 2021 Spark Testing ... or how to farm reputation on StackOverflowMay 2021 Spark Testing ... or how to farm reputation on StackOverflow
May 2021 Spark Testing ... or how to farm reputation on StackOverflowAdam Doyle
 
UNIT TESTING PPT
UNIT TESTING PPTUNIT TESTING PPT
UNIT TESTING PPTsuhasreddy1
 
Unit Testing and TDD 2017
Unit Testing and TDD 2017Unit Testing and TDD 2017
Unit Testing and TDD 2017Xavi Hidalgo
 
Google test training
Google test trainingGoogle test training
Google test trainingThierry Gayet
 
Unit Testing Fundamentals
Unit Testing FundamentalsUnit Testing Fundamentals
Unit Testing FundamentalsRichard Paul
 
Unit testing
Unit testingUnit testing
Unit testingAdam Birr
 
SELJE_Database_Unit_Testing_Slides.pdf
SELJE_Database_Unit_Testing_Slides.pdfSELJE_Database_Unit_Testing_Slides.pdf
SELJE_Database_Unit_Testing_Slides.pdfEric Selje
 
Test Driven Development with Sql Server
Test Driven Development with Sql ServerTest Driven Development with Sql Server
Test Driven Development with Sql ServerDavid P. Moore
 
Software Testing
Software TestingSoftware Testing
Software TestingAdroitLogic
 
Automated Testing with Databases
Automated Testing with DatabasesAutomated Testing with Databases
Automated Testing with Databaseselliando dias
 
Introduction of TestNG framework and its benefits over Junit framework
Introduction of TestNG framework and its benefits over Junit frameworkIntroduction of TestNG framework and its benefits over Junit framework
Introduction of TestNG framework and its benefits over Junit frameworkBugRaptors
 
An introduction to unit testing
An introduction to unit testingAn introduction to unit testing
An introduction to unit testingAdam Stephensen
 

Ähnlich wie Oracle Unit Testing with utPLSQL (20)

Test driven development and unit testing with examples in C++
Test driven development and unit testing with examples in C++Test driven development and unit testing with examples in C++
Test driven development and unit testing with examples in C++
 
JUnit- A Unit Testing Framework
JUnit- A Unit Testing FrameworkJUnit- A Unit Testing Framework
JUnit- A Unit Testing Framework
 
Test automation principles, terminologies and implementations
Test automation principles, terminologies and implementationsTest automation principles, terminologies and implementations
Test automation principles, terminologies and implementations
 
May 2021 Spark Testing ... or how to farm reputation on StackOverflow
May 2021 Spark Testing ... or how to farm reputation on StackOverflowMay 2021 Spark Testing ... or how to farm reputation on StackOverflow
May 2021 Spark Testing ... or how to farm reputation on StackOverflow
 
UNIT TESTING PPT
UNIT TESTING PPTUNIT TESTING PPT
UNIT TESTING PPT
 
Unit Testing and TDD 2017
Unit Testing and TDD 2017Unit Testing and TDD 2017
Unit Testing and TDD 2017
 
Test Driven
Test DrivenTest Driven
Test Driven
 
Google test training
Google test trainingGoogle test training
Google test training
 
Unit Testing
Unit TestingUnit Testing
Unit Testing
 
Unit Testing Fundamentals
Unit Testing FundamentalsUnit Testing Fundamentals
Unit Testing Fundamentals
 
Unit testing
Unit testingUnit testing
Unit testing
 
Unit testing
Unit testingUnit testing
Unit testing
 
SELJE_Database_Unit_Testing_Slides.pdf
SELJE_Database_Unit_Testing_Slides.pdfSELJE_Database_Unit_Testing_Slides.pdf
SELJE_Database_Unit_Testing_Slides.pdf
 
Test Driven Development with Sql Server
Test Driven Development with Sql ServerTest Driven Development with Sql Server
Test Driven Development with Sql Server
 
Unit testing, principles
Unit testing, principlesUnit testing, principles
Unit testing, principles
 
Software Testing
Software TestingSoftware Testing
Software Testing
 
Automated Testing with Databases
Automated Testing with DatabasesAutomated Testing with Databases
Automated Testing with Databases
 
TDD Best Practices
TDD Best PracticesTDD Best Practices
TDD Best Practices
 
Introduction of TestNG framework and its benefits over Junit framework
Introduction of TestNG framework and its benefits over Junit frameworkIntroduction of TestNG framework and its benefits over Junit framework
Introduction of TestNG framework and its benefits over Junit framework
 
An introduction to unit testing
An introduction to unit testingAn introduction to unit testing
An introduction to unit testing
 

Kürzlich hochgeladen

VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Natan Silnitsky
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Rob Geurden
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 

Kürzlich hochgeladen (20)

VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 

Oracle Unit Testing with utPLSQL

  • 1. Oracle Unit Testing with utPLSQL Brendan Furey, October 2015 http://aprogrammerwrites.eu/
  • 2. Agenda Manual vs Automated Unit Testing, and Agile (6 slides) utPLSQL vs Gherkin (2 slides) Working with utPLSQL (5 slides) utPLSQL Examples (2 slides) Oracle Unit Testing with utPLSQL 2Brendan Furey, 2015
  • 3. Manual vs Automated Unit Testing Unit testing on database is mostly manual up to now utPLSQL inspired by xUnit testing Automated unit testing on the database has additional challenges compared with Java unit testing for example Database developers express concerns about cost of automation Creator of utPLSQL admits he does not use it himself Checklist Driven Development: TDD on the cheap  "Doing full-blown test driven development (TDD) simply is not going to happen widely in the Oracle database programming world." Oracle Unit Testing with utPLSQL 3Brendan Furey, 2015
  • 4. Cost of Automated Testing Oracle Unit Testing with utPLSQL 4Brendan Furey, 2015
  • 5. Agile Changes the Equation Agile and TDD with ideas of smaller, more frequent changes Manual testing now too expensive Automation therefore required Overall cost may be smaller with automation Continuous Integration / Delivery changes everything! utPLSQL was ahead of its time initially (c.15 years ago) Oracle Unit Testing with utPLSQL 5Brendan Furey, 2015
  • 6. Example: Feature Cloning with Manual Testing New feature similar to an existing one (second version of web service maybe) Manual regression testing too costly, so refactoring rarely happens Copy and modify, end up with code duplication, larger code base Code becomes larger and less modular as time passes FDD - Fear Driven Development Oracle Unit Testing with utPLSQL 6Brendan Furey, 2015
  • 7. Example: Feature Cloning with Automated Testing  Refactor to reduce new code base, and re-use base and unit test code  Automated regression testing gives confidence to refactor safely  Code is continuously refined and improved  Less technical debt Oracle Unit Testing with utPLSQL 7Brendan Furey, 2015
  • 8. Testing Cycle: Pattern vs Antipattern Diagrams from software testing ice-cream cone Pyramid Ideal Pattern • Consider testing approaches with these in mind Icecream Cone Antipattern Oracle Unit Testing with utPLSQL 8Brendan Furey, 2015
  • 9. utPLSQL vs Gherkin 1: Gherkin  Some support for Cucumber and other Gherkin methods, but some opposition too:  Please don't use Cucumber  TDD: Where Did It All Go Wrong?  Driving motivation may be, as Ian Cooper suggests, due to poor understanding of TDD  Notably, focusing on implementation details, not behaviours  Defining all tests up front with QA, less iterative  Going out to Java problematic  May not be very agile?  Acceptance testing is generally less rigorous than good unit testing Oracle Unit Testing with utPLSQL 9Brendan Furey, 2015
  • 10. utPLSQL vs Gherkin 2: utPLSQL  Processing in base code is of same nature as that of unit testing code, hence well-suited to database language PL/SQL  Developer can start with a single test  Make it work  Add additional tests and make them work iteratively  Tests are exclusively behavioural, eliminating need for repeated unit testing up the pyramid  More of a TDD approach  QA will focus on integration tests and avoid unit testing  Currently QA tend to do unit testing after developers have done theirs  Symptom of icecream cone antipattern  QA will validate the development unit tests Oracle Unit Testing with utPLSQL 10Brendan Furey, 2015
  • 11. Working with utPLSQL 1: Home Page utPLSQL Home Page Steve Feuerstein's Recommendations for unit testing PL/SQL programs "utPLSQL is free and gives you total control over your test code. But that's mostly because you have to write all the test code" "If you are allergic to UI-based testing and/or worry about being constrained by an IDE's feature set (in other words, you are a command line fanatic), utPLSQL offers a powerful alternative." Oracle Unit Testing with utPLSQL 11Brendan Furey, 2015
  • 12. Working with utPLSQL 2: Structure  CREATE OR REPLACE PACKAGE ut_package IS  PROCEDURE ut_setup;  PROCEDURE ut_teardown;   PROCEDURE ut_proc;  END ut_package;  Think in design patterns  One web service procedure may be based on the code for an earlier one  Use similar coding strategies  Generic array types can help here  Modularise just as with base code  Behaviours only tested, no implementation tests  Large set of ‘assert’ procedures: may be simpler to just cast to strings and assert string equality Oracle Unit Testing with utPLSQL 12Brendan Furey, 2015
  • 13. Working with utPLSQL 3: Improving the Output Output format not great, but use a wrapper assert procedure  Can group tests by category such as normal/edge/exception etc.  Tabular output of expected vs actuals  Count tests and failures by group Also summarise by suite Unit tests succeed or fail, but:  Can add useful information, such as code timings (I have small footprint code timer)  May help to diagnose a sudden performance problem Oracle Unit Testing with utPLSQL 13Brendan Furey, 2015
  • 14. Working with utPLSQL 4: Coding Strategies 1 – data structures etc. Drive by data structures rather than case by case in program logic Use arrays for test data setup, for calling parameters and for expected results Use arrays to store meaningful test descriptions Concatenate fields in a record to reduce number of assertions Use utility procedures to transform a range to a range category for assertion, eg NOW = 'in last ten minutes', PAST = 'earlier than 10 minutes ago' Use generic arrays rather than creating new record or object types for each test case Oracle Unit Testing with utPLSQL 14Brendan Furey, 2015
  • 15. Working with utPLSQL 5: Coding Strategies 2 - DML Use special DML APIs for the test data Parametrise important fields Use dummy values for other mandatory fields for simplicity to avoid passing parameters; maybe index- suffix them Ignore non-mandatory fields that don't figure in the testing May be best to keep simple, and avoid over-sharing Oracle Unit Testing with utPLSQL 15Brendan Furey, 2015
  • 16. utPLSQL Example 1: Simple Table API API to merge reference data into a table Runs via suite (although only 1 test set in suite) Oracle Unit Testing with utPLSQL 16Brendan Furey, 2015
  • 17. utPLSQL Example 2: Web Service Procedure with Batch Denormalisation  Batch job runs to pre-populate a table for performance reasons  Test records for each type of driving entity  Test each outer-join by including record with missing join  Check output table record values  Check output table record counts for the input test set  Web service procedure reads the table and outputs a reference cursor  Input is an array of records  Array of input arrays for all combinations of inputs  Test program calls procedure for each input, then reads the output cursor into an array  Again test counts and record values against expected value arrays Oracle Unit Testing with utPLSQL 17Brendan Furey, 2015