Home > SQL Developer Dialog Boxes ... > Unit Testing: Create Unit Test
Use this wizard to create a unit test. (The SQL Developer unit testing feature is explained in SQL Developer: Unit Testing.) To go from one step to the next, click Next; to go back to the previous step, click Back.
Select Operation
Select a database connection on the right, then use the hierarchy tree to select an object to be tested. For example, to test a procedure, expand the Procedures node and select the desired procedure.
Specify Test Name
Test Name: Name for the unit test. Can be the same as the name of the database object (for example, procedure or function) to be tested.
Create with single dummy representation: Creates a single (sometimes called "one-off") test case for which you must specify the input parameter values when you run the test.
Select/create implementation using lookup values: Generates multiple test cases using sets of input parameter values that you will specify.
Specify Startup
Specify the action to perform at the start of the test, before any of the actual test operations are performed. Reasons for using a startup action might include the following:
You want to create copies of the entire table or specific rows that will be modified by the test, so that you can restore the original values later during teardown.
You want to perform some special operations before the test is run.
None: Perform no startup action.
Row Copy: Copy rows from a specified table. You will be asked to specify the table and q query for selecting the rows.
Table Copy: Copy a specified table. You will be asked to specify the table. For example, you might want to copy the EMPLOYEES table to a table named EMPLOYEES_ORIGINAL.
User PL/SQL Code: Run a script. You will be asked to specify the script file.
Specify Parameters
If you are creating a single test case, specify the parameter values in the Input column for each input parameter. For example, for the example award_bonus
procedure, you might test the case where employee ID 1001 sold 5000 dollars work of goods or services (EMP_ID Input: 1001, SALES_AMT Input: 5000).
If you are creating multiple test cases, specify the information for each parameter for each test case. For example, to create a test with 5 test cases for the example award_bonus
procedure, you need to enter 10 rows on this page (2 input parameters times 5 test cases).
Specify Validations
Specify one or more validation actions to perform after the test case is run, to check whether the desired result was returned. For example, if a test case for a procedure was supposed to increase the salary for employee number 1001 to $2000, specify a Query returning row(s)
validation of SELECT salary FROM employees WHERE employee_id = 1001 AND salary = 2000
.
For all validation action options except None, you will be prompted to specify the required information.
To add a validation action for a test case, click the Add (+) icon; to delete a validation action for a test case, select it and click the Remove (X) icon.
None: Perform no validation action.
Boolean function: Validation succeeds if Boolean TRUE
is returned by the specified function.
Query returning no row(s): Validation succeeds if the specified query returns no rows.
Query returning row(s): Validation succeeds if the specified query returns one or more rows that satisfy the specified query.
Result Set Compare: Validation succeeds if the results returned by the specified query match the values that you specify.
Table Compare: Validation succeeds if the target table (the table modified by the test case) is identical to the specified table.
User PL/SQL Code: Validation succeeds if the specified script runs successfully.
Specify Teardown
Specify the action to perform after the validation action (or the test case in no validation action was specified) is finished. Reasons for using a teardown action might include the following:
You want to restore a table to its original values, effectively "rolling back" any changes that were made by the test case.
You want to perform some special operations after the test is run.
None: Perform no teardown action.
Table Drop: Drop (delete) the specified table.
Table Restore: Replace all rows in the specified target table (the table modified by the test case) with the rows in the specified source table. For example, you might want to replace the contents of EMPLOYEES (target) table with a source table named EMPLOYEES_ORIGINAL.
User PL/SQL Code: Run a script. You will be asked to specify the script file.
Summary
Displays the selected options. To make any changes, click Back. To perform the operation, click Finish.
Related Topics