Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
e41d6f9
Interim commit with lots of dirty code - got to a place where I get t…
jgebal Oct 30, 2018
f475b7c
Added `suite_cache`.
jgebal Nov 2, 2018
4dc48e6
Interim commit - performance check on Travis.
jgebal Nov 4, 2018
1611e09
Interim commit some fixes to old tests, examples and code itself.
jgebal Nov 4, 2018
15163a8
Resolved issue with sorting of nested-tables.
jgebal Nov 4, 2018
1b14bb5
Fixing re-enabled test.
jgebal Nov 4, 2018
3bc8da5
Adding missing items to uninstall.
jgebal Nov 4, 2018
8911f97
Small improvements and cleanup.
jgebal Nov 5, 2018
a1f6b34
Removing duplicate with block.
jgebal Nov 6, 2018
59f7738
Adding cache cleanup and "intelligent" join to all_source, only when …
jgebal Nov 11, 2018
cb9cf97
Resolving some sonar violations.
jgebal Nov 11, 2018
8779025
Moving away from full outer join.
jgebal Nov 11, 2018
b3e98be
Reorganizing code a bit.
jgebal Nov 11, 2018
64dfb41
Output buffer&reporters performance improvements
jgebal Nov 12, 2018
9ea805b
Increased fetch size for coverage sources tmp seeding.
jgebal Nov 12, 2018
248bf8c
Small refactoring.
jgebal Nov 13, 2018
8fc2ea6
Further optimizations to suite parsing.
jgebal Nov 15, 2018
3543e3d
Disabled `PLSQL_OPTIMIZE_LEVEL=0` for testing
jgebal Nov 15, 2018
23c0557
Fixed formal parameter names
jgebal Nov 15, 2018
f7f6811
Revert "Disabled `PLSQL_OPTIMIZE_LEVEL=0` for testing"
jgebal Nov 15, 2018
d002d18
Refactored procedure `get_unit_test_info` to return more relevant inf…
jgebal Nov 16, 2018
e1f1eec
Renamed `get_unit_test_info` to `get_suites_info` - the latter one wa…
jgebal Nov 16, 2018
d8d251f
Improved automation of `refresh_sources.sh`
jgebal Nov 16, 2018
eb3df21
Fixing failing test.
jgebal Nov 16, 2018
d211348
Added control over rollback behavior in `ut_runner.run`
jgebal Nov 17, 2018
f342195
Reverting rollback changes - they should go as a separate PR.
jgebal Nov 17, 2018
eeae79b
Added documentation for new functionality.
jgebal Nov 17, 2018
74ec9a1
Removed unused code.
jgebal Nov 18, 2018
44d61d9
Recovering exception handlers as they are needed for handling invalid…
jgebal Nov 18, 2018
360a889
Moved some of old tests into new tests.
jgebal Nov 18, 2018
0ee3ce2
Added missing endcontext in `test_ut_test`
jgebal Nov 18, 2018
48aa338
Removed unused constants.
jgebal Nov 18, 2018
b33aaae
Added additional test for display of parser warnings.
jgebal Nov 18, 2018
e8ea644
Merge branch 'develop' into feature/suite_query_api
jgebal Nov 18, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added documentation for new functionality.
Added default value for owner, when calling `get_suites_info`
  • Loading branch information
jgebal committed Nov 17, 2018
commit eeae79be2df3efad9c8a58a54407470afbda1d8a
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The framework follows industry standards and best patterns of modern Unit Testin
- [Expectations](userguide/expectations.md)
- [Advanced data comparison](userguide/advanced_data_comparison.md)
- [Running unit tests](userguide/running-unit-tests.md)
- [Querying for test suites](userguide/querying_suites.md)
- [Testing best pracitces](userguide/best-practices.md)
- [Upgrade utPLSQL](userguide/upgrade.md)
- Reporting
Expand Down
83 changes: 83 additions & 0 deletions docs/userguide/querying_suites.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Qyerying for test suites


## Obtaining information about suites

utPLSQL framework provides ability to read inforamtion about unit test suites that exist in a schema.

Pipelined table function `ut_runner.get_suites_info(a_owner, a_package_name)` allows you to retrieve information about:

- all suites that exist in a given user/schema
- individual test suite pacakage

Querying the data from function provides the follwing details:

- `object_owner` - the owner of test suite packages
- `object_name` - the name of test suite package
- `item_name` - the name of suite/test
- `item_description` - the description of suite/suite item
- `item_type` - the type of item (UT_SUITE/UT_SUITE_CONTEXT/UT_TEST/UT_LOGICAL_SUITE)
- `item_line_no` - line_number where annotation identifying the item exists
- `path` - suitepath of the item
- `disabled_flag` - (0/1) indicator if item is disabled by --%disabled annotation

To get list of all test suites in current schema
```sql
select * from table(ut_runner.get_suites_info()) where item_type = 'UT_SUITE';
```

To get list of all tests for test suite `TEST_STUFF` in current user schema
```sql
select * from table(ut_runner.get_suites_info(USER, 'TEST_STUFF')) where item_type = 'UT_TEST';
```

To get a full information about suite `TEST_STUFF` including suite description, all contexts and tests in a suite
```sql
select * from table(ut_runner.get_suites_info(USER, 'TEST_STUFF')) where item_type = 'UT_TEST';
```

## Checking if schema contains tests

Function `ut_runner.has_suites(a_owner)` returns boolean value indicating if given schema contains test suites.

Example:
```sql
begin
if ut_runner.has_suites(USER) then
dbms_output.put_line( 'User '||USER||' owns test suites' );
else
dbms_output.put_line( 'User '||USER||' does not own test suites' );
end if;
end;
```

## Checking if package is a test suite

Function `ut_runner.is_suite(a_owner, a_package_name) ` returns boolean value indicating if given package is a test suites.

Example:
```sql
begin
if ut_runner.is_suite(USER,'TEST_STUFF') then
dbms_output.put_line( 'Package '||USER||'.TEST_STUFF is a test suite' );
else
dbms_output.put_line( 'Package '||USER||'.TEST_STUFF is not a test suite' );
end if;
end;
```

## Checking if procedure is a test within a suite

Function `ut_runner.is_test(a_owner, a_package_name, a_procedure_name) ` returns boolean value indicating if given package is a test suites.

Example:
```sql
begin
if ut_runner.is_test(USER,'TEST_STUFF','A_TEST_TO_CHECK_STUFF') then
dbms_output.put_line( 'Procedure '||USER||'.TEST_STUFF.A_TEST_TO_CHECK_STUFF is a test' );
else
dbms_output.put_line( 'Procedure '||USER||'.TEST_STUFF.A_TEST_TO_CHECK_STUFF is not a test' );
end if;
end;
```

4 changes: 2 additions & 2 deletions docs/userguide/running-unit-tests.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Running tests

The utPLSQL framework provides two main entry points to run unit tests from within the database:
utPLSQL framework provides two main entry points to run unit tests from within the database:

- `ut.run` procedures and functions
- `ut_runner.run` procedures

These two entry points differ in purpose and behavior.
Most of the time you will want to use `ut.run` as `ut_runner` is designed for API integration and does not output the results to the screen directly.
Most of the time you will want to use `ut.run` as `ut_runner.run` is designed for API integration and does not display the results to the screen.

# Running from CI servers and command line

Expand Down
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ nav:
- Expectations: userguide/expectations.md
- Advanced data comparison: userguide/advanced_data_comparison.md
- Running unit tests: userguide/running-unit-tests.md
- Querying for test suites: userguide/querying_suites.md
- Testing best pracitces: userguide/best-practices.md
- Upgrade utPLSQL: userguide/upgrade.md
- Reporting:
Expand Down
4 changes: 2 additions & 2 deletions source/api/ut_runner.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,12 @@ create or replace package body ut_runner is
ut_annotation_manager.purge_cache(a_object_owner, a_object_type);
end;

function get_suites_info(a_owner varchar2, a_package_name varchar2 := null) return ut_suite_items_info pipelined is
function get_suites_info(a_owner varchar2 := null, a_package_name varchar2 := null) return ut_suite_items_info pipelined is
l_cursor sys_refcursor;
l_results ut_suite_items_info;
c_bulk_limit constant integer := 10;
begin
l_cursor := ut_suite_manager.get_suites_info( a_owner, a_package_name );
l_cursor := ut_suite_manager.get_suites_info( nvl(a_owner,sys_context('userenv', 'current_schema')), a_package_name );
loop
fetch l_cursor bulk collect into l_results limit c_bulk_limit;
for i in 1 .. l_results.count loop
Expand Down
6 changes: 3 additions & 3 deletions source/api/ut_runner.pks
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ create or replace package ut_runner authid current_user is
/**
* Returns a pipelined collection containing information about unit test suites and the tests contained in them
*
* @param a_owner owner of unit tests to retrieve
* @param a_package_name optional name of unit test package to retrieve, if NULLm all unit test packages are returned
* @param a_owner owner of unit tests to retrieve (optional), if NULL, current schema is used
* @param a_package_name name of unit test package to retrieve (optional), if NULL all unit test packages are returned
* @return ut_suite_items_info table of objects
*/
function get_suites_info(a_owner varchar2, a_package_name varchar2 := null) return ut_suite_items_info pipelined;
function get_suites_info(a_owner varchar2 := null, a_package_name varchar2 := null) return ut_suite_items_info pipelined;


/**
Expand Down
2 changes: 1 addition & 1 deletion test/api/test_ut_runner.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ end;';
'dummy_test_package.some_dummy_test_procedure' path, 0 disabled_flag
from dual;
--Act
open l_actual for select * from table(ut3.ut_runner.get_suites_info('UT3_TESTER','DUMMY_TEST_PACKAGE'));
open l_actual for select * from table(ut3.ut_runner.get_suites_info(NULL,'DUMMY_TEST_PACKAGE'));
--Assert
ut.expect(l_actual).to_equal(l_expected);
end;
Expand Down