|
| 1 | +# Qyerying for test suites |
| 2 | + |
| 3 | + |
| 4 | +## Obtaining information about suites |
| 5 | + |
| 6 | +utPLSQL framework provides ability to read inforamtion about unit test suites that exist in a schema. |
| 7 | + |
| 8 | +Pipelined table function `ut_runner.get_suites_info(a_owner, a_package_name)` allows you to retrieve information about: |
| 9 | + |
| 10 | +- all suites that exist in a given user/schema |
| 11 | +- individual test suite pacakage |
| 12 | + |
| 13 | +Querying the data from function provides the follwing details: |
| 14 | + |
| 15 | +- `object_owner` - the owner of test suite packages |
| 16 | +- `object_name` - the name of test suite package |
| 17 | +- `item_name` - the name of suite/test |
| 18 | +- `item_description` - the description of suite/suite item |
| 19 | +- `item_type` - the type of item (UT_SUITE/UT_SUITE_CONTEXT/UT_TEST/UT_LOGICAL_SUITE) |
| 20 | +- `item_line_no` - line_number where annotation identifying the item exists |
| 21 | +- `path` - suitepath of the item |
| 22 | +- `disabled_flag` - (0/1) indicator if item is disabled by --%disabled annotation |
| 23 | + |
| 24 | +To get list of all test suites in current schema |
| 25 | +```sql |
| 26 | +select * from table(ut_runner.get_suites_info()) where item_type = 'UT_SUITE'; |
| 27 | +``` |
| 28 | + |
| 29 | +To get list of all tests for test suite `TEST_STUFF` in current user schema |
| 30 | +```sql |
| 31 | +select * from table(ut_runner.get_suites_info(USER, 'TEST_STUFF')) where item_type = 'UT_TEST'; |
| 32 | +``` |
| 33 | + |
| 34 | +To get a full information about suite `TEST_STUFF` including suite description, all contexts and tests in a suite |
| 35 | +```sql |
| 36 | +select * from table(ut_runner.get_suites_info(USER, 'TEST_STUFF')) where item_type = 'UT_TEST'; |
| 37 | +``` |
| 38 | + |
| 39 | +## Checking if schema contains tests |
| 40 | + |
| 41 | +Function `ut_runner.has_suites(a_owner)` returns boolean value indicating if given schema contains test suites. |
| 42 | + |
| 43 | +Example: |
| 44 | +```sql |
| 45 | +begin |
| 46 | + if ut_runner.has_suites(USER) then |
| 47 | + dbms_output.put_line( 'User '||USER||' owns test suites' ); |
| 48 | + else |
| 49 | + dbms_output.put_line( 'User '||USER||' does not own test suites' ); |
| 50 | + end if; |
| 51 | +end; |
| 52 | +``` |
| 53 | + |
| 54 | +## Checking if package is a test suite |
| 55 | + |
| 56 | +Function `ut_runner.is_suite(a_owner, a_package_name) ` returns boolean value indicating if given package is a test suites. |
| 57 | + |
| 58 | +Example: |
| 59 | +```sql |
| 60 | +begin |
| 61 | + if ut_runner.is_suite(USER,'TEST_STUFF') then |
| 62 | + dbms_output.put_line( 'Package '||USER||'.TEST_STUFF is a test suite' ); |
| 63 | + else |
| 64 | + dbms_output.put_line( 'Package '||USER||'.TEST_STUFF is not a test suite' ); |
| 65 | + end if; |
| 66 | +end; |
| 67 | +``` |
| 68 | + |
| 69 | +## Checking if procedure is a test within a suite |
| 70 | + |
| 71 | +Function `ut_runner.is_test(a_owner, a_package_name, a_procedure_name) ` returns boolean value indicating if given package is a test suites. |
| 72 | + |
| 73 | +Example: |
| 74 | +```sql |
| 75 | +begin |
| 76 | + if ut_runner.is_test(USER,'TEST_STUFF','A_TEST_TO_CHECK_STUFF') then |
| 77 | + dbms_output.put_line( 'Procedure '||USER||'.TEST_STUFF.A_TEST_TO_CHECK_STUFF is a test' ); |
| 78 | + else |
| 79 | + dbms_output.put_line( 'Procedure '||USER||'.TEST_STUFF.A_TEST_TO_CHECK_STUFF is not a test' ); |
| 80 | + end if; |
| 81 | +end; |
| 82 | +``` |
| 83 | + |
0 commit comments