17-6. Building a utPLSQL Test Suite

Problem

You have created numerous unit test procedures that you must run every time you modify your code. Running each test individually is both time-consuming and error-prone, as you may forget to run a test or two. You need a simple method to run all of your tests at once.

Solution

Use the utsuite.add command of utPLSQL to build a test suite, use the utPackage.add command to add individual unit tests to it, and then run the result. For example, here's how to build a suite to run the unit tests you developed in Recipes 17-3 and 17-4.

Create the test suite.

exec utSuite.add ('My Test Suite', 'Test all my functions'),

Add individual unit tests to the suite.

exec utPackage.add ('My Test Suite', 'calc_quarter_hour'),
exec utPackage.add ('My Test Suite', 'factorial'),

Run the test suite. See recipe 17-7.

How It Works

The utSuite.add routine creates a new test suite using the text in the first parameter as its unique name. Note that the utPLSQL utility uppercases the suite name before saving, so take that into consideration, as suite names must be unique. The second parameter is descriptive text for your test suite.

Once the suite is created, use the utPackage.add procedure to add existing unit tests to the suite. The first parameter must match the name of an existing test suite. The second parameter is the name of the unit test to run. As more unit tests are developed, they can be added to the suite to provide an easy method to run all tests at once.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.2.78