Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ node_modules/
utPLSQL_latest_release/
utPLSQL-cli/
development/env.sh
development/*.jar
*.log

# exclusions based on artifacts created via actions documented in CONTRIBUTING.md
Expand Down
8 changes: 6 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,18 @@ export CONNECTION_STR=127.0.0.1:1521/xe # Adjust the connect string
export ORACLE_PWD=oracle # Adjust your local SYS password
```

### Download Oracle JDBC drivers

Download `ojdbc8-xxx.jar` and `orai18n-xxx.jar` from [Oracle](https://www.oracle.com/technetwork/database/features/jdbc/jdbc-ucp-122-3110062.html).
Place them in `development` directory of the project.


### Download utPLSQL release sources and utplsq-cli

The below script is fetching latest release version from utPLSQL repository. Latest release version is used for self-testing.
```bash
development/refresh_sources.sh
```
> **Important notice:**
> You'll have to provide the ojdbc.jar in the folder utPLSQL-cli/lib manually due to Oracle licensing restrictions.

### Setup local database for utPLSQL development

Expand Down
1 change: 1 addition & 0 deletions development/refresh_sources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ curl -Lk -o utPLSQL-cli.zip https://github.com/utPLSQL/utPLSQL-cli/releases/down
# unzip utPLSQL-cli and remove the zip file
unzip utPLSQL-cli.zip && chmod u+x utPLSQL-cli/bin/utplsql && rm utPLSQL-cli.zip

cp development/*.jar utPLSQL-cli/lib/
3 changes: 2 additions & 1 deletion development/releasing.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ To create a release:
- wait for th build to complete successfully
- merge the release branch to master and wait for master build to complete successfully
- create a release from the master branch using [github releases page](https://github.com/utPLSQL/utPLSQL/releases) and populate release description using information found on the issues and pull requests since previous release.
To find issues closed after certain date use [advanced filters](https://help.github.com/articles/searching-issues-and-pull-requests/#search-by-open-or-closed-state)
To find issues closed after certain date use [advanced filters](https://help.github.com/articles/searching-issues-and-pull-requests/#search-by-open-or-closed-state).
Example: [`is:issue closed:>2018-07-22`](https://github.com/utPLSQL/utPLSQL/issues?utf8=%E2%9C%93&q=is%3Aissue+closed%3A%3E2018-07-22+)

The following will happen:
- build executed on branch `release/vX.Y.Z-[something]` updates files `sonar-project.properties`, `VERSION` with project version derived from the release branch name
Expand Down
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
2 changes: 0 additions & 2 deletions examples/RunDeveloperExamples.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ set linesize 1000

exec ut_ansiconsole_helper.color_enabled(true);
--developer examples
prompt RunExampleComplexSuiteWithCustomReporter
@@developer_examples/RunExampleComplexSuiteWithCustomReporter.sql
prompt RunExampleTestSuiteWithCustomReporter
@@developer_examples/RunExampleTestSuiteWithCustomReporter.sql
prompt RunExampleTestAnnotationsParsingTimeHugePackage
Expand Down

This file was deleted.

12 changes: 7 additions & 5 deletions examples/developer_examples/RunExampleTestSuite.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,21 @@ declare
l_test ut_test;
l_expectation ut_expectation_result;
begin
l_suite := ut_suite(user, 'ut_exampletest');
l_suite := ut_suite(user, 'ut_exampletest',a_line_no=>1);
l_suite.description := 'Test Suite Name';
l_test := ut_test(user, 'ut_exampletest','ut_exAmpletest');
l_test := ut_test(user, 'ut_exampletest','ut_exAmpletest',a_line_no=>3);
l_test.description := 'Example test1';
l_test.before_test_list := ut_executables(ut_executable(user, 'ut_exampletest','Setup',ut_utils.gc_before_test));
l_test.after_test_list := ut_executables(ut_executable(user, 'ut_exampletest','tEardown',ut_utils.gc_after_test));
l_suite.add_item(l_test);
l_suite.items.extend;
l_suite.items(l_suite.items.last) := l_test;

l_test := ut_test(user, 'UT_EXAMPLETEST2','ut_exAmpletest');
l_test := ut_test(user, 'UT_EXAMPLETEST2','ut_exAmpletest',a_line_no=>6);
l_test.description := 'Another example test';
l_test.before_test_list := ut_executables(ut_executable(user, 'UT_EXAMPLETEST2','SETUP',ut_utils.gc_before_test));
l_test.after_test_list := ut_executables(ut_executable(user, 'UT_EXAMPLETEST2','TEARDOWN',ut_utils.gc_after_test));
l_suite.add_item(l_test);
l_suite.items.extend;
l_suite.items(l_suite.items.last) := l_test;

l_suite.do_execute();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ set echo off

PROMPT Runs test report using composite reporter
declare
suite ut_logical_suite;
l_suite ut_logical_suite;
l_doc_reporter ut_output_reporter_base := ut_documentation_reporter();
l_tc_reporter ut_output_reporter_base := ut_teamcity_reporter();
l_run ut_run;
Expand All @@ -21,14 +21,16 @@ begin
ut_event_manager.add_listener(l_doc_reporter);
ut_event_manager.add_listener(l_tc_reporter);

suite := ut_suite(user, 'ut_exampletest');
suite.description := 'Test Suite Name';
l_suite := ut_suite(user, 'ut_exampletest',a_line_no=>1);
l_suite.description := 'Test Suite Name';

suite.add_item(ut_test(user,'ut_exampletest','ut_exAmpletest'));
suite.add_item(ut_test(user, 'UT_EXAMPLETEST2','UT_EXAMPLETEST'));
l_suite.items.extend;
l_suite.items(l_suite.items.last) := ut_test(user,'ut_exampletest','ut_exAmpletest',a_line_no=>3);
l_suite.items.extend;
l_suite.items(l_suite.items.last) := ut_test(user, 'UT_EXAMPLETEST2','UT_EXAMPLETEST',a_line_no=>6);

-- provide a reporter to process results
l_run := ut_run(ut_suite_items(suite));
l_run := ut_run(ut_suite_items(l_suite));
l_run.do_execute();

ut_event_manager.trigger_event(ut_utils.gc_finalize, l_run);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,21 @@ begin
ut_event_manager.initialize();
-- Install ut_custom_reporter first from example folder

l_suite := ut_suite(user, 'ut_exampletest');
l_suite := ut_suite(user, 'ut_exampletest',a_line_no=>1);

l_test := ut_test(user, 'ut_exampletest','ut_exAmpletest');
l_test := ut_test(user, 'ut_exampletest','ut_exAmpletest',a_line_no=>3);
l_test.description := 'Example test1';
l_test.before_test_list := ut_executables(ut_executable(user, 'ut_exampletest','Setup',ut_utils.gc_before_test));
l_test.after_test_list := ut_executables(ut_executable(user, 'ut_exampletest','tEardown',ut_utils.gc_after_test));
l_suite.add_item(l_test);
l_suite.items.extend;
l_suite.items(l_suite.items.last) := l_test;

l_test := ut_test(user, 'UT_EXAMPLETEST2','ut_exAmpletest');
l_test := ut_test(user, 'UT_EXAMPLETEST2','ut_exAmpletest',a_line_no=>6);
l_test.description := 'Another example test';
l_test.before_test_list := ut_executables(ut_executable(user, 'ut_exampletest','SETUP',ut_utils.gc_before_test));
l_test.after_test_list := ut_executables(ut_executable(user, 'ut_exampletest','TEARDOWN',ut_utils.gc_after_test));
l_suite.add_item(l_test);
l_suite.items.extend;
l_suite.items(l_suite.items.last) := l_test;

-- provide a reporter to process results tabbing each hierarcy level by tab_size
l_reporter := ut_custom_reporter(a_tab_size => 2);
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
Loading