SlideShare a Scribd company logo
Copyright 2006 Steven Feuerstein - Page 1
Six Simple Steps
to
Unit Testing
Happiness
By Steven Feuerstein
2019 note: I offer this for a reflection back
to 2006 and my talks on testing. I now work
for Oracle. My slides look much nicer. J
Contact me at
steven.feuerstein@oracle.com
Copyright 2006 Steven Feuerstein - Page 2
Writing software is.....
Copyright 2006 Steven Feuerstein - Page 3
Testing software is.....
Copyright 2006 Steven Feuerstein - Page 4
Buggy software is....
§Embarrassing
§Expensive
§Deadly
Copyright 2006 Steven Feuerstein - Page 5
Buggy software is embarrassing
§ There can be as many as 20 to 30 bugs per 1,000
lines of software code. —Sustainable Computing
Consortium
§ 32% of organizations say that they release software
with too many defects.—Cutter Consortium
§ 38% of organizations believe they lack an adequate
software quality assurance program.—Cutter
Consortium
§ 27% of organizations do not conduct any formal
quality reviews.—Cutter Consortium
§ Developers spend about 80% of development costs
on identifying and correcting defects.—The National
Institute of Standards and Technology
Copyright 2006 Steven Feuerstein - Page 6
Buggy software is expensive -
$60B per year in US alone!?
§ JUNE 25, 2002 (COMPUTERWORLD) -
WASHINGTON -- Software bugs are costing the
U.S. economy an estimated $59.5 billion each
year. Of the total $59.5 billion cost, users
incurred 64% of the cost and developers 36%.
§ There are very few markets where "buyers are
willing to accept products that they know are
going to malfunction," said Gregory Tassey, the
National Institute of Standards and Technology
senior economist who headed the study. "But
software is at the extreme end in terms of errors
or bugs that are in the typical product when it is
sold."
§ Oh, yes and Y2K: $300B? $600B?
Copyright 2006 Steven Feuerstein - Page 7
Buggy software is deadly
§ 2003 Software failure contributes to power outage across
the Northeastern U.S. and Canada, killing 3 people.
§ 2001 Five Panamanian cancer patients die following
overdoses of radiation, amounts of which were determined
by faulty use of software.
§ 2000 Crash of a Marine Corps Osprey tilt-rotor aircraft
partially blamed on “software anomaly" kills four soldiers.
§ 1997 Radar that could have prevented Korean jet crash
(killing 225) hobbled by software problem.
§ 1995 American Airlines jet, descending into Cali, Colombia,
crashes into a mountain, killing 159. Jury holds maker of
flight-management system 17% responsible. A report by
the University of Bielefeld in Germany found that the
software presented insufficient and conflicting information
to the pilots, who got lost.
Copyright 2006 Steven Feuerstein - Page 8
How do we avoid buggy software?
§ Clear and accurate requirements
§ Careful design
§ Excellent tools
§ Best practices, standards, guidelines (that is,
follow them)
§ Code review
§ Thorough testing
Uh oh...
the world is in
big trouble.
Copyright 2006 Steven Feuerstein - Page 9
Wouldn't it be so nice if...
§ You could easily construct your tests?
– You didn't have to wonder how to write the test code, how to
perform complex tests.
§ You could easily run those tests?
– And see the results, instantly and automatically.
§ You could actually have the time to both construct
and run those tests?
– Writing and maintaining test code takes so much time!
§ You knew with certainty that your program worked,
you didn't just guess or hope.
Copyright 2006 Steven Feuerstein - Page 10
Different types of testing
§ There are many types of testing:
functional/system tests, stress tests, unit
tests...
§ A "unit test" is the test of a single unit of code.
– Also known as a programmer test
§ Unit tests are the responsibility of developers -
that is, us, the people in this room.
– Not fundamentally a job for the QA department, which
generally focuses on functional and system tests.
Copyright 2006 Steven Feuerstein - Page 11
Truth or Dare
§ How do you (or your team) unit test
your PL/SQL code today?
– We use automated testing software.
– We have a formal test process that we each
follow, but otherwise a manual process.
– Everyone does their own thing and we
hope for the best.
– Our users test our code.
?
?
?
?
Copyright 2006 Steven Feuerstein - Page 12
Typical Testing
§ DBMS_OUTPUT.PUT_LINE - unit testing
mechanism of choice?
betwnstr.sf
betwnstr.tst
BEGIN
DBMS_OUTPUT.PUT_LINE (betwnstr (NULL, 3, 5, true));
DBMS_OUTPUT.PUT_LINE (betwnstr ('abcdefgh', 0, 5, true));
DBMS_OUTPUT.PUT_LINE (betwnstr ('abcdefgh', 3, 5, true));
DBMS_OUTPUT.PUT_LINE (betwnstr ('abcdefgh', -3, -5, true));
DBMS_OUTPUT.PUT_LINE (betwnstr ('abcdefgh', NULL, 5, true));
DBMS_OUTPUT.PUT_LINE (betwnstr ('abcdefgh', 3, NULL, true));
DBMS_OUTPUT.PUT_LINE (betwnstr ('abcdefgh', 3, 100, true));
END;
There has got to be a better way!
Copyright 2006 Steven Feuerstein - Page 13
Moving towards a Better Way
§ Change from within: your code will not test itself.
– You must accept the responsibility and then be disciplined.
– Commit to testing and watch the way you write your code
change.
§ Change from without: you need testing tools.
– utPLSQL
– SQL Developer integrated unit testing
– Others….
§ Hey, what about those six, simple steps?
Copyright 2006 Steven Feuerstein - Page 14
Six Simple Steps to Unit Testing Happiness
Define
Req’ments
1 Construct
Header
2 Define
Tests
3 Build
Test Code
4
Build /
Fix Code
5
Test CodeDebug
6
The Build
CycleBug
Report
Enhance.
Request
Post-
Production
Copyright 2006 Steven Feuerstein - Page 15
Six Simple Steps...Elaborated
§ 1. Describe fully the required functionality of the program.
– Don’t start coding until you are sure you understand what is needed, and be ready to engage
with your user on all levels (technical, business, ethical, etc.)
§ 2. Define the header of the program (name, parameter list, return value).
– Once you do that, you can compile a “stub” of that program.
§ 3. Come up with at least an initial set of test cases for the program.
– Think about what it will take to prove your program works.
§ 4. Build test code that implements all test cases.
– Ah...the truly challenging step.
§ 5. Write the program unit.
– Back to your comfort zone, but now you are building against a test plan.
§ 6. Test, debug, fix, test, debug, fix, test, debug....
– We never get it right the first time.
§ Then...repeat steps 3-6 for each enhancement and bug report.
– Every bug report highlights two bugs: one in your code and another in your test case.
Copyright 2006 Steven Feuerstein - Page 16
1. Describe required functionality
§ I need a variation of SUBSTR that will return the
portion of a string between specified start and end
locations.
§ Some specific requirements:
– It should work like SUBSTR as much as makes sense (treat
a start location of 0 as 1, for example; if the end location is
past the end of the string, the treat it as the end of the
string).
– Negative start and end should return a substring at the end
of the string.
– Allow the user to specify whether or not the endpoints
should be included.
Copyright 2006 Steven Feuerstein - Page 17
2. Define the program specification
§ My specification or header should be compatible
with all requirements.
– I also self-document that the function is deterministic: no
side effects.
§ I can (and will) now create a compile-able stub
for the program. Why do that?
– Because I can then fully define and implement my test code!
FUNCTION betwnstr (
string_in IN VARCHAR2
, start_in IN PLS_INTEGER
, end_in IN PLS_INTEGER
, inclusive_in IN BOOLEAN DEFAULT TRUE
)
RETURN VARCHAR2 DETERMINISTIC
betwnstr0.sf
Copyright 2006 Steven Feuerstein - Page 18
3. Elaborate the test cases
§ Before I write any code, I will come up with as many of
the test cases as possible -- and write my test code.
– This is known as "test-driven development". TDD is a very hot topic
among developers and is associated with Agile Software
(http://agilemanifesto.org/) and Extreme Programming.
§ Putting aside the fancy names and methodologies, TDD
makes perfect sense -- when you stop to think about it.
If you write your program before you define your
tests, how do you know you when you're done?
TNT or TDD?
And if you write your tests afterward, you are likely
to prejudice your tests to show "success."
Copyright 2006 Steven Feuerstein - Page 19
Some of the test cases for BETWNSTR
§ Start and end within the string ("normal" usage)
§ Start of 0
§ End past end of string
§ Null string, string of single character, 32767 len character
§ Null start and/or end
§ Negative start and end
§ Start larger than end (positive and negative)
§ Variations of the above with different inclusive values
Don't be overwhelmed by the total number of cases. Start out
with a representative sampling. You can always add from there.
But now a big challenge: where do you put this test case
information? Tie it as closely as possible to your code.
Copyright 2006 Steven Feuerstein - Page 20
4. Testcases and Test Code
§ The challenge (terror?) of the blank screen....
– How do I define the test cases?
– How do I set up those tests?
– How do I verify the results?
§ Let's see how Quest Code Tester for Oracle
helps me tackle these challenges.
– Define and maintain your test cases through a graphical
interface, then let it do all the work.
Copyright 2006 Steven Feuerstein - Page 21
4. Don't write test code – describe tests
§ Rather than write test code, describe the tests you
need through a graphical interface.
– It’s just like SQL vs. programming.
§ Code Tester saves your descriptions in a test
repository.
– Critical information, especially for IT management
§ It generates a PL/SQL test package based on your
descriptions.
§ It runs the test at your request and displays the
results.
Time for some software magic....
Copyright 2006 Steven Feuerstein - Page 22
6. Test, debug, fix, test, debug, fix, test, debug...
§ With a test script in place, I can quickly and easily
move back and forth between running my program,
identifying errors, debugging and fixing the code,
running the program again.
§ I also then have my test process and regression test
in place so that as I make enhancements or fix bugs, I
can fall back on this foundation.
– It is critical that you maintain your test case definitions
and test code as your program evolves.
– And update those first -- before you change the program!
Copyright 2006 Steven Feuerstein - Page 23
Change Your Testing Ways
§ Testing tools can make a dramatic difference
in your ability to test and your confidence in
the resulting code.
§ Build a comprehensive "library" of unit tests
as you build your application
– These tests and all their test cases can be passed on to
other developers
– Anyone can now enhance or maintain the code with
confidence. Make your changes and run the tests. If you
get a green light, you're OK!
Copyright 2006 Steven Feuerstein - Page 24
Testing: Baby steps better than paralysis.
§ Unit testing is an intimidating process.
– You are never really done.
– You have to maintain your test code along with your
application code.
§ But every incremental improvement in testing
yields immediate and long-term benefits.
– Don't worry about 100% test coverage.

More Related Content

What's hot

All About PL/SQL Collections
All About PL/SQL CollectionsAll About PL/SQL Collections
All About PL/SQL Collections
Steven Feuerstein
 
Social Media - Why a Database Person Should Care
Social Media  - Why a Database Person Should CareSocial Media  - Why a Database Person Should Care
Social Media - Why a Database Person Should Care
Jeff Smith
 
Pennsylvania Banner User Group Webinar: Oracle SQL Developer Tips & Tricks
Pennsylvania Banner User Group Webinar: Oracle SQL Developer Tips & TricksPennsylvania Banner User Group Webinar: Oracle SQL Developer Tips & Tricks
Pennsylvania Banner User Group Webinar: Oracle SQL Developer Tips & Tricks
Jeff Smith
 
RESTful Services for your Oracle Autonomous Database
RESTful Services for your Oracle Autonomous DatabaseRESTful Services for your Oracle Autonomous Database
RESTful Services for your Oracle Autonomous Database
Jeff Smith
 
Oracle SQL Developer: You're Doing it Wrong!
Oracle SQL Developer: You're Doing it Wrong!Oracle SQL Developer: You're Doing it Wrong!
Oracle SQL Developer: You're Doing it Wrong!
Jeff Smith
 
Oracle SQL Developer Reports
Oracle SQL Developer ReportsOracle SQL Developer Reports
Oracle SQL Developer Reports
Jeff Smith
 
What's New in Oracle SQL Developer for 2018
What's New in Oracle SQL Developer for 2018What's New in Oracle SQL Developer for 2018
What's New in Oracle SQL Developer for 2018
Jeff Smith
 
Debugging PL/SQL from your APEX Applications with Oracle SQL Developer
Debugging PL/SQL from your APEX Applications with Oracle SQL DeveloperDebugging PL/SQL from your APEX Applications with Oracle SQL Developer
Debugging PL/SQL from your APEX Applications with Oracle SQL Developer
Jeff Smith
 
Oracle Database Management REST API
Oracle Database Management REST APIOracle Database Management REST API
Oracle Database Management REST API
Jeff Smith
 
05 managing transactions
05   managing transactions05   managing transactions
05 managing transactions
Марина Босова
 
Oracle SQL Developer - POUG 2018
Oracle SQL Developer - POUG 2018Oracle SQL Developer - POUG 2018
Oracle SQL Developer - POUG 2018
Sabine Heimsath
 
How To Learn Programming For Beginners | How To Start Coding | Learn Programm...
How To Learn Programming For Beginners | How To Start Coding | Learn Programm...How To Learn Programming For Beginners | How To Start Coding | Learn Programm...
How To Learn Programming For Beginners | How To Start Coding | Learn Programm...
Simplilearn
 
LOBS, BLOBS, CLOBS: Dealing with Attachments in APEX
LOBS, BLOBS, CLOBS: Dealing with Attachments in APEXLOBS, BLOBS, CLOBS: Dealing with Attachments in APEX
LOBS, BLOBS, CLOBS: Dealing with Attachments in APEX
Enkitec
 
Automated testing APEX Applications
Automated testing APEX ApplicationsAutomated testing APEX Applications
Automated testing APEX Applications
Roel Hartman
 
The Ember.js Framework - Everything You Need To Know
The Ember.js Framework - Everything You Need To KnowThe Ember.js Framework - Everything You Need To Know
The Ember.js Framework - Everything You Need To Know
All Things Open
 
EVOLVE'13 | Keynote | Roy Fielding
EVOLVE'13 | Keynote | Roy FieldingEVOLVE'13 | Keynote | Roy Fielding
EVOLVE'13 | Keynote | Roy Fielding
Evolve The Adobe Digital Marketing Community
 
Mobile APIs: Optimizing APIs for Many Devices
Mobile APIs: Optimizing APIs for Many DevicesMobile APIs: Optimizing APIs for Many Devices
Mobile APIs: Optimizing APIs for Many Devices
Apigee | Google Cloud
 
Not All Heroes Wear Capes: Skills and Tools Helpful in Becoming a Support Sup...
Not All Heroes Wear Capes: Skills and Tools Helpful in Becoming a Support Sup...Not All Heroes Wear Capes: Skills and Tools Helpful in Becoming a Support Sup...
Not All Heroes Wear Capes: Skills and Tools Helpful in Becoming a Support Sup...
Atlassian
 
Londons Calling 2021
Londons Calling 2021Londons Calling 2021
Londons Calling 2021
Keir Bowden
 
London's calling 2020 Documentor Plug-In
London's calling 2020 Documentor Plug-InLondon's calling 2020 Documentor Plug-In
London's calling 2020 Documentor Plug-In
Keir Bowden
 

What's hot (20)

All About PL/SQL Collections
All About PL/SQL CollectionsAll About PL/SQL Collections
All About PL/SQL Collections
 
Social Media - Why a Database Person Should Care
Social Media  - Why a Database Person Should CareSocial Media  - Why a Database Person Should Care
Social Media - Why a Database Person Should Care
 
Pennsylvania Banner User Group Webinar: Oracle SQL Developer Tips & Tricks
Pennsylvania Banner User Group Webinar: Oracle SQL Developer Tips & TricksPennsylvania Banner User Group Webinar: Oracle SQL Developer Tips & Tricks
Pennsylvania Banner User Group Webinar: Oracle SQL Developer Tips & Tricks
 
RESTful Services for your Oracle Autonomous Database
RESTful Services for your Oracle Autonomous DatabaseRESTful Services for your Oracle Autonomous Database
RESTful Services for your Oracle Autonomous Database
 
Oracle SQL Developer: You're Doing it Wrong!
Oracle SQL Developer: You're Doing it Wrong!Oracle SQL Developer: You're Doing it Wrong!
Oracle SQL Developer: You're Doing it Wrong!
 
Oracle SQL Developer Reports
Oracle SQL Developer ReportsOracle SQL Developer Reports
Oracle SQL Developer Reports
 
What's New in Oracle SQL Developer for 2018
What's New in Oracle SQL Developer for 2018What's New in Oracle SQL Developer for 2018
What's New in Oracle SQL Developer for 2018
 
Debugging PL/SQL from your APEX Applications with Oracle SQL Developer
Debugging PL/SQL from your APEX Applications with Oracle SQL DeveloperDebugging PL/SQL from your APEX Applications with Oracle SQL Developer
Debugging PL/SQL from your APEX Applications with Oracle SQL Developer
 
Oracle Database Management REST API
Oracle Database Management REST APIOracle Database Management REST API
Oracle Database Management REST API
 
05 managing transactions
05   managing transactions05   managing transactions
05 managing transactions
 
Oracle SQL Developer - POUG 2018
Oracle SQL Developer - POUG 2018Oracle SQL Developer - POUG 2018
Oracle SQL Developer - POUG 2018
 
How To Learn Programming For Beginners | How To Start Coding | Learn Programm...
How To Learn Programming For Beginners | How To Start Coding | Learn Programm...How To Learn Programming For Beginners | How To Start Coding | Learn Programm...
How To Learn Programming For Beginners | How To Start Coding | Learn Programm...
 
LOBS, BLOBS, CLOBS: Dealing with Attachments in APEX
LOBS, BLOBS, CLOBS: Dealing with Attachments in APEXLOBS, BLOBS, CLOBS: Dealing with Attachments in APEX
LOBS, BLOBS, CLOBS: Dealing with Attachments in APEX
 
Automated testing APEX Applications
Automated testing APEX ApplicationsAutomated testing APEX Applications
Automated testing APEX Applications
 
The Ember.js Framework - Everything You Need To Know
The Ember.js Framework - Everything You Need To KnowThe Ember.js Framework - Everything You Need To Know
The Ember.js Framework - Everything You Need To Know
 
EVOLVE'13 | Keynote | Roy Fielding
EVOLVE'13 | Keynote | Roy FieldingEVOLVE'13 | Keynote | Roy Fielding
EVOLVE'13 | Keynote | Roy Fielding
 
Mobile APIs: Optimizing APIs for Many Devices
Mobile APIs: Optimizing APIs for Many DevicesMobile APIs: Optimizing APIs for Many Devices
Mobile APIs: Optimizing APIs for Many Devices
 
Not All Heroes Wear Capes: Skills and Tools Helpful in Becoming a Support Sup...
Not All Heroes Wear Capes: Skills and Tools Helpful in Becoming a Support Sup...Not All Heroes Wear Capes: Skills and Tools Helpful in Becoming a Support Sup...
Not All Heroes Wear Capes: Skills and Tools Helpful in Becoming a Support Sup...
 
Londons Calling 2021
Londons Calling 2021Londons Calling 2021
Londons Calling 2021
 
London's calling 2020 Documentor Plug-In
London's calling 2020 Documentor Plug-InLondon's calling 2020 Documentor Plug-In
London's calling 2020 Documentor Plug-In
 

Similar to Six simple steps to unit testing happiness

It’s Time to Automate Your Exploratory Testing
It’s Time to Automate Your Exploratory TestingIt’s Time to Automate Your Exploratory Testing
It’s Time to Automate Your Exploratory Testing
TechWell
 
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in FlexassertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
michael.labriola
 
Black box testing lecture 11
Black box testing lecture 11Black box testing lecture 11
Black box testing lecture 11
Abdul Basit
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
ZendCon
 
Review of an open source unit test tool- Cucumber_Presentation
Review of an open source unit test tool- Cucumber_PresentationReview of an open source unit test tool- Cucumber_Presentation
Review of an open source unit test tool- Cucumber_Presentation
Jabeen Shazia Posses H1 B Visa (Jazz)
 
Unit Testing
Unit TestingUnit Testing
Unit Testing
Anuj Arora
 
Why Unit Testingl
Why Unit TestinglWhy Unit Testingl
Why Unit Testingl
priya_trivedi
 
Why unit testingl
Why unit testinglWhy unit testingl
Why unit testingl
Priya Sharma
 
Why Unit Testingl
Why Unit TestinglWhy Unit Testingl
Why Unit Testingl
priya_trivedi
 
5 Essential Tips for Load Testing Beginners
5 Essential Tips for Load Testing Beginners5 Essential Tips for Load Testing Beginners
5 Essential Tips for Load Testing Beginners
Neotys
 
Software Development Lifecycle Presentation
Software Development Lifecycle PresentationSoftware Development Lifecycle Presentation
Software Development Lifecycle Presentation
ssuser645e24
 
Black box testing
Black box testingBlack box testing
Black box testing
Abdul Basit
 
Computer Software Testing Basics introduced.ppt
Computer Software Testing Basics introduced.pptComputer Software Testing Basics introduced.ppt
Computer Software Testing Basics introduced.ppt
TrevorChinguwo
 
software testing
software testingsoftware testing
software testing
choclatyhero007
 
A beginners guide to testing
A beginners guide to testingA beginners guide to testing
A beginners guide to testing
Philip Johnson
 
Lessons Learned in Software Development: QA Infrastructure – Maintaining Rob...
Lessons Learned in Software Development: QA Infrastructure – Maintaining Rob...Lessons Learned in Software Development: QA Infrastructure – Maintaining Rob...
Lessons Learned in Software Development: QA Infrastructure – Maintaining Rob...
Cωνσtantίnoς Giannoulis
 
Testing: the more you do it, the more you'll like it
Testing: the more you do it, the more you'll like itTesting: the more you do it, the more you'll like it
Testing: the more you do it, the more you'll like it
Jeffrey McGuire
 
5-Ways-to-Revolutionize-Your-Software-Testing
5-Ways-to-Revolutionize-Your-Software-Testing5-Ways-to-Revolutionize-Your-Software-Testing
5-Ways-to-Revolutionize-Your-Software-Testing
Mary Clemons
 
Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...
Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...
Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...
mCloud
 
Software Testing
Software TestingSoftware Testing
Software Testing
Vishal Singh
 

Similar to Six simple steps to unit testing happiness (20)

It’s Time to Automate Your Exploratory Testing
It’s Time to Automate Your Exploratory TestingIt’s Time to Automate Your Exploratory Testing
It’s Time to Automate Your Exploratory Testing
 
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in FlexassertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
 
Black box testing lecture 11
Black box testing lecture 11Black box testing lecture 11
Black box testing lecture 11
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Review of an open source unit test tool- Cucumber_Presentation
Review of an open source unit test tool- Cucumber_PresentationReview of an open source unit test tool- Cucumber_Presentation
Review of an open source unit test tool- Cucumber_Presentation
 
Unit Testing
Unit TestingUnit Testing
Unit Testing
 
Why Unit Testingl
Why Unit TestinglWhy Unit Testingl
Why Unit Testingl
 
Why unit testingl
Why unit testinglWhy unit testingl
Why unit testingl
 
Why Unit Testingl
Why Unit TestinglWhy Unit Testingl
Why Unit Testingl
 
5 Essential Tips for Load Testing Beginners
5 Essential Tips for Load Testing Beginners5 Essential Tips for Load Testing Beginners
5 Essential Tips for Load Testing Beginners
 
Software Development Lifecycle Presentation
Software Development Lifecycle PresentationSoftware Development Lifecycle Presentation
Software Development Lifecycle Presentation
 
Black box testing
Black box testingBlack box testing
Black box testing
 
Computer Software Testing Basics introduced.ppt
Computer Software Testing Basics introduced.pptComputer Software Testing Basics introduced.ppt
Computer Software Testing Basics introduced.ppt
 
software testing
software testingsoftware testing
software testing
 
A beginners guide to testing
A beginners guide to testingA beginners guide to testing
A beginners guide to testing
 
Lessons Learned in Software Development: QA Infrastructure – Maintaining Rob...
Lessons Learned in Software Development: QA Infrastructure – Maintaining Rob...Lessons Learned in Software Development: QA Infrastructure – Maintaining Rob...
Lessons Learned in Software Development: QA Infrastructure – Maintaining Rob...
 
Testing: the more you do it, the more you'll like it
Testing: the more you do it, the more you'll like itTesting: the more you do it, the more you'll like it
Testing: the more you do it, the more you'll like it
 
5-Ways-to-Revolutionize-Your-Software-Testing
5-Ways-to-Revolutionize-Your-Software-Testing5-Ways-to-Revolutionize-Your-Software-Testing
5-Ways-to-Revolutionize-Your-Software-Testing
 
Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...
Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...
Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...
 
Software Testing
Software TestingSoftware Testing
Software Testing
 

More from Steven Feuerstein

New(er) Stuff in PL/SQL
New(er) Stuff in PL/SQLNew(er) Stuff in PL/SQL
New(er) Stuff in PL/SQL
Steven Feuerstein
 
Speakers at Nov 2019 PL/SQL Office Hours session
Speakers at Nov 2019 PL/SQL Office Hours sessionSpeakers at Nov 2019 PL/SQL Office Hours session
Speakers at Nov 2019 PL/SQL Office Hours session
Steven Feuerstein
 
New Stuff in the Oracle PL/SQL Language
New Stuff in the Oracle PL/SQL LanguageNew Stuff in the Oracle PL/SQL Language
New Stuff in the Oracle PL/SQL Language
Steven Feuerstein
 
Error Management Features of PL/SQL
Error Management Features of PL/SQLError Management Features of PL/SQL
Error Management Features of PL/SQL
Steven Feuerstein
 
High Performance PL/SQL
High Performance PL/SQLHigh Performance PL/SQL
High Performance PL/SQL
Steven Feuerstein
 
Oracle PL/SQL 12c and 18c New Features + RADstack + Community Sites
Oracle PL/SQL 12c and 18c New Features + RADstack + Community SitesOracle PL/SQL 12c and 18c New Features + RADstack + Community Sites
Oracle PL/SQL 12c and 18c New Features + RADstack + Community Sites
Steven Feuerstein
 
Unit Testing Oracle PL/SQL Code: utPLSQL, Excel and More
Unit Testing Oracle PL/SQL Code: utPLSQL, Excel and MoreUnit Testing Oracle PL/SQL Code: utPLSQL, Excel and More
Unit Testing Oracle PL/SQL Code: utPLSQL, Excel and More
Steven Feuerstein
 
Impact Analysis with PL/Scope
Impact Analysis with PL/ScopeImpact Analysis with PL/Scope
Impact Analysis with PL/Scope
Steven Feuerstein
 
The Amazing and Elegant PL/SQL Function Result Cache
The Amazing and Elegant PL/SQL Function Result CacheThe Amazing and Elegant PL/SQL Function Result Cache
The Amazing and Elegant PL/SQL Function Result Cache
Steven Feuerstein
 
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
Steven Feuerstein
 
utPLSQL: Unit Testing for Oracle PL/SQL
utPLSQL: Unit Testing for Oracle PL/SQLutPLSQL: Unit Testing for Oracle PL/SQL
utPLSQL: Unit Testing for Oracle PL/SQL
Steven Feuerstein
 

More from Steven Feuerstein (11)

New(er) Stuff in PL/SQL
New(er) Stuff in PL/SQLNew(er) Stuff in PL/SQL
New(er) Stuff in PL/SQL
 
Speakers at Nov 2019 PL/SQL Office Hours session
Speakers at Nov 2019 PL/SQL Office Hours sessionSpeakers at Nov 2019 PL/SQL Office Hours session
Speakers at Nov 2019 PL/SQL Office Hours session
 
New Stuff in the Oracle PL/SQL Language
New Stuff in the Oracle PL/SQL LanguageNew Stuff in the Oracle PL/SQL Language
New Stuff in the Oracle PL/SQL Language
 
Error Management Features of PL/SQL
Error Management Features of PL/SQLError Management Features of PL/SQL
Error Management Features of PL/SQL
 
High Performance PL/SQL
High Performance PL/SQLHigh Performance PL/SQL
High Performance PL/SQL
 
Oracle PL/SQL 12c and 18c New Features + RADstack + Community Sites
Oracle PL/SQL 12c and 18c New Features + RADstack + Community SitesOracle PL/SQL 12c and 18c New Features + RADstack + Community Sites
Oracle PL/SQL 12c and 18c New Features + RADstack + Community Sites
 
Unit Testing Oracle PL/SQL Code: utPLSQL, Excel and More
Unit Testing Oracle PL/SQL Code: utPLSQL, Excel and MoreUnit Testing Oracle PL/SQL Code: utPLSQL, Excel and More
Unit Testing Oracle PL/SQL Code: utPLSQL, Excel and More
 
Impact Analysis with PL/Scope
Impact Analysis with PL/ScopeImpact Analysis with PL/Scope
Impact Analysis with PL/Scope
 
The Amazing and Elegant PL/SQL Function Result Cache
The Amazing and Elegant PL/SQL Function Result CacheThe Amazing and Elegant PL/SQL Function Result Cache
The Amazing and Elegant PL/SQL Function Result Cache
 
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
 
utPLSQL: Unit Testing for Oracle PL/SQL
utPLSQL: Unit Testing for Oracle PL/SQLutPLSQL: Unit Testing for Oracle PL/SQL
utPLSQL: Unit Testing for Oracle PL/SQL
 

Recently uploaded

Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Jeffrey Haguewood
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
Hiroshi SHIBATA
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Tosin Akinosho
 
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Jeffrey Haguewood
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
DanBrown980551
 
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStrDeep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
saastr
 
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - HiikeSystem Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
Hiike
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
saastr
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
dbms calicut university B. sc Cs 4th sem.pdf
dbms  calicut university B. sc Cs 4th sem.pdfdbms  calicut university B. sc Cs 4th sem.pdf
dbms calicut university B. sc Cs 4th sem.pdf
Shinana2
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
Azure API Management to expose backend services securely
Azure API Management to expose backend services securelyAzure API Management to expose backend services securely
Azure API Management to expose backend services securely
Dinusha Kumarasiri
 
Recommendation System using RAG Architecture
Recommendation System using RAG ArchitectureRecommendation System using RAG Architecture
Recommendation System using RAG Architecture
fredae14
 
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Tatiana Kojar
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
Zilliz
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
kumardaparthi1024
 
Finale of the Year: Apply for Next One!
Finale of the Year: Apply for Next One!Finale of the Year: Apply for Next One!
Finale of the Year: Apply for Next One!
GDSC PJATK
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 

Recently uploaded (20)

Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
 
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
 
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStrDeep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
 
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - HiikeSystem Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
dbms calicut university B. sc Cs 4th sem.pdf
dbms  calicut university B. sc Cs 4th sem.pdfdbms  calicut university B. sc Cs 4th sem.pdf
dbms calicut university B. sc Cs 4th sem.pdf
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
Azure API Management to expose backend services securely
Azure API Management to expose backend services securelyAzure API Management to expose backend services securely
Azure API Management to expose backend services securely
 
Recommendation System using RAG Architecture
Recommendation System using RAG ArchitectureRecommendation System using RAG Architecture
Recommendation System using RAG Architecture
 
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
 
Finale of the Year: Apply for Next One!
Finale of the Year: Apply for Next One!Finale of the Year: Apply for Next One!
Finale of the Year: Apply for Next One!
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 

Six simple steps to unit testing happiness

  • 1. Copyright 2006 Steven Feuerstein - Page 1 Six Simple Steps to Unit Testing Happiness By Steven Feuerstein 2019 note: I offer this for a reflection back to 2006 and my talks on testing. I now work for Oracle. My slides look much nicer. J Contact me at steven.feuerstein@oracle.com
  • 2. Copyright 2006 Steven Feuerstein - Page 2 Writing software is.....
  • 3. Copyright 2006 Steven Feuerstein - Page 3 Testing software is.....
  • 4. Copyright 2006 Steven Feuerstein - Page 4 Buggy software is.... §Embarrassing §Expensive §Deadly
  • 5. Copyright 2006 Steven Feuerstein - Page 5 Buggy software is embarrassing § There can be as many as 20 to 30 bugs per 1,000 lines of software code. —Sustainable Computing Consortium § 32% of organizations say that they release software with too many defects.—Cutter Consortium § 38% of organizations believe they lack an adequate software quality assurance program.—Cutter Consortium § 27% of organizations do not conduct any formal quality reviews.—Cutter Consortium § Developers spend about 80% of development costs on identifying and correcting defects.—The National Institute of Standards and Technology
  • 6. Copyright 2006 Steven Feuerstein - Page 6 Buggy software is expensive - $60B per year in US alone!? § JUNE 25, 2002 (COMPUTERWORLD) - WASHINGTON -- Software bugs are costing the U.S. economy an estimated $59.5 billion each year. Of the total $59.5 billion cost, users incurred 64% of the cost and developers 36%. § There are very few markets where "buyers are willing to accept products that they know are going to malfunction," said Gregory Tassey, the National Institute of Standards and Technology senior economist who headed the study. "But software is at the extreme end in terms of errors or bugs that are in the typical product when it is sold." § Oh, yes and Y2K: $300B? $600B?
  • 7. Copyright 2006 Steven Feuerstein - Page 7 Buggy software is deadly § 2003 Software failure contributes to power outage across the Northeastern U.S. and Canada, killing 3 people. § 2001 Five Panamanian cancer patients die following overdoses of radiation, amounts of which were determined by faulty use of software. § 2000 Crash of a Marine Corps Osprey tilt-rotor aircraft partially blamed on “software anomaly" kills four soldiers. § 1997 Radar that could have prevented Korean jet crash (killing 225) hobbled by software problem. § 1995 American Airlines jet, descending into Cali, Colombia, crashes into a mountain, killing 159. Jury holds maker of flight-management system 17% responsible. A report by the University of Bielefeld in Germany found that the software presented insufficient and conflicting information to the pilots, who got lost.
  • 8. Copyright 2006 Steven Feuerstein - Page 8 How do we avoid buggy software? § Clear and accurate requirements § Careful design § Excellent tools § Best practices, standards, guidelines (that is, follow them) § Code review § Thorough testing Uh oh... the world is in big trouble.
  • 9. Copyright 2006 Steven Feuerstein - Page 9 Wouldn't it be so nice if... § You could easily construct your tests? – You didn't have to wonder how to write the test code, how to perform complex tests. § You could easily run those tests? – And see the results, instantly and automatically. § You could actually have the time to both construct and run those tests? – Writing and maintaining test code takes so much time! § You knew with certainty that your program worked, you didn't just guess or hope.
  • 10. Copyright 2006 Steven Feuerstein - Page 10 Different types of testing § There are many types of testing: functional/system tests, stress tests, unit tests... § A "unit test" is the test of a single unit of code. – Also known as a programmer test § Unit tests are the responsibility of developers - that is, us, the people in this room. – Not fundamentally a job for the QA department, which generally focuses on functional and system tests.
  • 11. Copyright 2006 Steven Feuerstein - Page 11 Truth or Dare § How do you (or your team) unit test your PL/SQL code today? – We use automated testing software. – We have a formal test process that we each follow, but otherwise a manual process. – Everyone does their own thing and we hope for the best. – Our users test our code. ? ? ? ?
  • 12. Copyright 2006 Steven Feuerstein - Page 12 Typical Testing § DBMS_OUTPUT.PUT_LINE - unit testing mechanism of choice? betwnstr.sf betwnstr.tst BEGIN DBMS_OUTPUT.PUT_LINE (betwnstr (NULL, 3, 5, true)); DBMS_OUTPUT.PUT_LINE (betwnstr ('abcdefgh', 0, 5, true)); DBMS_OUTPUT.PUT_LINE (betwnstr ('abcdefgh', 3, 5, true)); DBMS_OUTPUT.PUT_LINE (betwnstr ('abcdefgh', -3, -5, true)); DBMS_OUTPUT.PUT_LINE (betwnstr ('abcdefgh', NULL, 5, true)); DBMS_OUTPUT.PUT_LINE (betwnstr ('abcdefgh', 3, NULL, true)); DBMS_OUTPUT.PUT_LINE (betwnstr ('abcdefgh', 3, 100, true)); END; There has got to be a better way!
  • 13. Copyright 2006 Steven Feuerstein - Page 13 Moving towards a Better Way § Change from within: your code will not test itself. – You must accept the responsibility and then be disciplined. – Commit to testing and watch the way you write your code change. § Change from without: you need testing tools. – utPLSQL – SQL Developer integrated unit testing – Others…. § Hey, what about those six, simple steps?
  • 14. Copyright 2006 Steven Feuerstein - Page 14 Six Simple Steps to Unit Testing Happiness Define Req’ments 1 Construct Header 2 Define Tests 3 Build Test Code 4 Build / Fix Code 5 Test CodeDebug 6 The Build CycleBug Report Enhance. Request Post- Production
  • 15. Copyright 2006 Steven Feuerstein - Page 15 Six Simple Steps...Elaborated § 1. Describe fully the required functionality of the program. – Don’t start coding until you are sure you understand what is needed, and be ready to engage with your user on all levels (technical, business, ethical, etc.) § 2. Define the header of the program (name, parameter list, return value). – Once you do that, you can compile a “stub” of that program. § 3. Come up with at least an initial set of test cases for the program. – Think about what it will take to prove your program works. § 4. Build test code that implements all test cases. – Ah...the truly challenging step. § 5. Write the program unit. – Back to your comfort zone, but now you are building against a test plan. § 6. Test, debug, fix, test, debug, fix, test, debug.... – We never get it right the first time. § Then...repeat steps 3-6 for each enhancement and bug report. – Every bug report highlights two bugs: one in your code and another in your test case.
  • 16. Copyright 2006 Steven Feuerstein - Page 16 1. Describe required functionality § I need a variation of SUBSTR that will return the portion of a string between specified start and end locations. § Some specific requirements: – It should work like SUBSTR as much as makes sense (treat a start location of 0 as 1, for example; if the end location is past the end of the string, the treat it as the end of the string). – Negative start and end should return a substring at the end of the string. – Allow the user to specify whether or not the endpoints should be included.
  • 17. Copyright 2006 Steven Feuerstein - Page 17 2. Define the program specification § My specification or header should be compatible with all requirements. – I also self-document that the function is deterministic: no side effects. § I can (and will) now create a compile-able stub for the program. Why do that? – Because I can then fully define and implement my test code! FUNCTION betwnstr ( string_in IN VARCHAR2 , start_in IN PLS_INTEGER , end_in IN PLS_INTEGER , inclusive_in IN BOOLEAN DEFAULT TRUE ) RETURN VARCHAR2 DETERMINISTIC betwnstr0.sf
  • 18. Copyright 2006 Steven Feuerstein - Page 18 3. Elaborate the test cases § Before I write any code, I will come up with as many of the test cases as possible -- and write my test code. – This is known as "test-driven development". TDD is a very hot topic among developers and is associated with Agile Software (http://agilemanifesto.org/) and Extreme Programming. § Putting aside the fancy names and methodologies, TDD makes perfect sense -- when you stop to think about it. If you write your program before you define your tests, how do you know you when you're done? TNT or TDD? And if you write your tests afterward, you are likely to prejudice your tests to show "success."
  • 19. Copyright 2006 Steven Feuerstein - Page 19 Some of the test cases for BETWNSTR § Start and end within the string ("normal" usage) § Start of 0 § End past end of string § Null string, string of single character, 32767 len character § Null start and/or end § Negative start and end § Start larger than end (positive and negative) § Variations of the above with different inclusive values Don't be overwhelmed by the total number of cases. Start out with a representative sampling. You can always add from there. But now a big challenge: where do you put this test case information? Tie it as closely as possible to your code.
  • 20. Copyright 2006 Steven Feuerstein - Page 20 4. Testcases and Test Code § The challenge (terror?) of the blank screen.... – How do I define the test cases? – How do I set up those tests? – How do I verify the results? § Let's see how Quest Code Tester for Oracle helps me tackle these challenges. – Define and maintain your test cases through a graphical interface, then let it do all the work.
  • 21. Copyright 2006 Steven Feuerstein - Page 21 4. Don't write test code – describe tests § Rather than write test code, describe the tests you need through a graphical interface. – It’s just like SQL vs. programming. § Code Tester saves your descriptions in a test repository. – Critical information, especially for IT management § It generates a PL/SQL test package based on your descriptions. § It runs the test at your request and displays the results. Time for some software magic....
  • 22. Copyright 2006 Steven Feuerstein - Page 22 6. Test, debug, fix, test, debug, fix, test, debug... § With a test script in place, I can quickly and easily move back and forth between running my program, identifying errors, debugging and fixing the code, running the program again. § I also then have my test process and regression test in place so that as I make enhancements or fix bugs, I can fall back on this foundation. – It is critical that you maintain your test case definitions and test code as your program evolves. – And update those first -- before you change the program!
  • 23. Copyright 2006 Steven Feuerstein - Page 23 Change Your Testing Ways § Testing tools can make a dramatic difference in your ability to test and your confidence in the resulting code. § Build a comprehensive "library" of unit tests as you build your application – These tests and all their test cases can be passed on to other developers – Anyone can now enhance or maintain the code with confidence. Make your changes and run the tests. If you get a green light, you're OK!
  • 24. Copyright 2006 Steven Feuerstein - Page 24 Testing: Baby steps better than paralysis. § Unit testing is an intimidating process. – You are never really done. – You have to maintain your test code along with your application code. § But every incremental improvement in testing yields immediate and long-term benefits. – Don't worry about 100% test coverage.