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

Skip to content

Commit 3a1227e

Browse files
authored
Merge pull request #783 from utPLSQL/feature/suite_query_api
Adding suite check API & performance improvements
2 parents d887889 + e8ea644 commit 3a1227e

125 files changed

Lines changed: 3624 additions & 2460 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ node_modules/
1515
utPLSQL_latest_release/
1616
utPLSQL-cli/
1717
development/env.sh
18+
development/*.jar
1819
*.log
1920

2021
# exclusions based on artifacts created via actions documented in CONTRIBUTING.md

CONTRIBUTING.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,18 @@ export CONNECTION_STR=127.0.0.1:1521/xe # Adjust the connect string
8989
export ORACLE_PWD=oracle # Adjust your local SYS password
9090
```
9191

92+
### Download Oracle JDBC drivers
93+
94+
Download `ojdbc8-xxx.jar` and `orai18n-xxx.jar` from [Oracle](https://www.oracle.com/technetwork/database/features/jdbc/jdbc-ucp-122-3110062.html).
95+
Place them in `development` directory of the project.
96+
97+
9298
### Download utPLSQL release sources and utplsq-cli
9399

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

101105
### Setup local database for utPLSQL development
102106

development/refresh_sources.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ curl -Lk -o utPLSQL-cli.zip https://github.com/utPLSQL/utPLSQL-cli/releases/down
1616
# unzip utPLSQL-cli and remove the zip file
1717
unzip utPLSQL-cli.zip && chmod u+x utPLSQL-cli/bin/utplsql && rm utPLSQL-cli.zip
1818

19+
cp development/*.jar utPLSQL-cli/lib/

development/releasing.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ To create a release:
99
- wait for th build to complete successfully
1010
- merge the release branch to master and wait for master build to complete successfully
1111
- 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.
12-
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)
12+
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).
13+
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+)
1314

1415
The following will happen:
1516
- build executed on branch `release/vX.Y.Z-[something]` updates files `sonar-project.properties`, `VERSION` with project version derived from the release branch name

docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ The framework follows industry standards and best patterns of modern Unit Testin
1010
- [Expectations](userguide/expectations.md)
1111
- [Advanced data comparison](userguide/advanced_data_comparison.md)
1212
- [Running unit tests](userguide/running-unit-tests.md)
13+
- [Querying for test suites](userguide/querying_suites.md)
1314
- [Testing best pracitces](userguide/best-practices.md)
1415
- [Upgrade utPLSQL](userguide/upgrade.md)
1516
- Reporting

docs/userguide/querying_suites.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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+

docs/userguide/running-unit-tests.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Running tests
22

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

55
- `ut.run` procedures and functions
66
- `ut_runner.run` procedures
77

88
These two entry points differ in purpose and behavior.
9-
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.
9+
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.
1010

1111
# Running from CI servers and command line
1212

examples/RunDeveloperExamples.sql

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ set linesize 1000
66

77
exec ut_ansiconsole_helper.color_enabled(true);
88
--developer examples
9-
prompt RunExampleComplexSuiteWithCustomReporter
10-
@@developer_examples/RunExampleComplexSuiteWithCustomReporter.sql
119
prompt RunExampleTestSuiteWithCustomReporter
1210
@@developer_examples/RunExampleTestSuiteWithCustomReporter.sql
1311
prompt RunExampleTestAnnotationsParsingTimeHugePackage

examples/developer_examples/RunExampleComplexSuiteWithCustomReporter.sql

Lines changed: 0 additions & 56 deletions
This file was deleted.

examples/developer_examples/RunExampleTestSuite.sql

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,21 @@ declare
1515
l_test ut_test;
1616
l_expectation ut_expectation_result;
1717
begin
18-
l_suite := ut_suite(user, 'ut_exampletest');
18+
l_suite := ut_suite(user, 'ut_exampletest',a_line_no=>1);
1919
l_suite.description := 'Test Suite Name';
20-
l_test := ut_test(user, 'ut_exampletest','ut_exAmpletest');
20+
l_test := ut_test(user, 'ut_exampletest','ut_exAmpletest',a_line_no=>3);
2121
l_test.description := 'Example test1';
2222
l_test.before_test_list := ut_executables(ut_executable(user, 'ut_exampletest','Setup',ut_utils.gc_before_test));
2323
l_test.after_test_list := ut_executables(ut_executable(user, 'ut_exampletest','tEardown',ut_utils.gc_after_test));
24-
l_suite.add_item(l_test);
24+
l_suite.items.extend;
25+
l_suite.items(l_suite.items.last) := l_test;
2526

26-
l_test := ut_test(user, 'UT_EXAMPLETEST2','ut_exAmpletest');
27+
l_test := ut_test(user, 'UT_EXAMPLETEST2','ut_exAmpletest',a_line_no=>6);
2728
l_test.description := 'Another example test';
2829
l_test.before_test_list := ut_executables(ut_executable(user, 'UT_EXAMPLETEST2','SETUP',ut_utils.gc_before_test));
2930
l_test.after_test_list := ut_executables(ut_executable(user, 'UT_EXAMPLETEST2','TEARDOWN',ut_utils.gc_after_test));
30-
l_suite.add_item(l_test);
31+
l_suite.items.extend;
32+
l_suite.items(l_suite.items.last) := l_test;
3133

3234
l_suite.do_execute();
3335

0 commit comments

Comments
 (0)