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

Skip to content

Commit b1e6b97

Browse files
committed
Added images for reporters.
Added documentation for reporters and runnin-uni-tests Added documentation for ut_run-script
1 parent 412e002 commit b1e6b97

10 files changed

Lines changed: 269 additions & 14 deletions
21.6 KB
Loading
22.1 KB
Loading
109 KB
Loading
173 KB
Loading
41.3 KB
Loading
51.2 KB
Loading

docs/userguide/reporters.md

Lines changed: 94 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,94 @@
1-
#Unit Test reporters
2-
TODO
1+
utPLSQL provides the following reporting formats.
2+
3+
#Documentation reporter
4+
5+
The `ut_documentation_reporter` is the default reporting format used by the framework.
6+
It provides a human readable test results.
7+
8+
To invoke tests with documentation reporter use one of following calls from sql console (SQLPlus)
9+
10+
`exec ut.run();`
11+
12+
`exec ut.run(ut_documentation_reporter());`
13+
14+
You may also invoke unit tests directly from command line by calling.
15+
16+
`sqlplus /nolog @ut_run %user%/%pass%@%dbsid%`
17+
18+
Invoking tests from command line tool `ut_run.sql` allows you to track progress of test execution.
19+
In that case, the documentation reporter will provide information about each test that was executed as soon as it's execution finishes.
20+
For more details on using the `ut_run.sql` script look into [ut_run.sql](ut_run-script.md) documentation.
21+
22+
The `ut_documentation_reporter` doesn't accept any arguments.
23+
24+
Example outputs from documentation reporter.
25+
26+
![doc_reporter_outputs](images/documentation_reporter.png)
27+
28+
The documentation report provides the following information.
29+
- Test suite name or test package name (nested with suitepath if suitepath is used)
30+
- Test description name or test procedure name
31+
- Information about test failing `(FAILED - n)`
32+
- Information about disabled test `(IGNORED)`
33+
- List of all errors and failures
34+
- Summary with total number of tests, number of tests with status and timing for the execution
35+
36+
37+
##Color output from documentation reporter
38+
39+
When invoking tests with documentation reporter and your command line supports ANSICONSOLE (default on Unix), you can obtain the coloured outputs from the documentation reporter.
40+
41+
To invoke tests with documentation reporter in color mode use one of following calls.
42+
43+
`exec ut.run(a_color_console=>true);`
44+
45+
`exec ut.run(ut_documentation_reporter(), a_color_console=>true);`
46+
47+
Example outputs from documentation reporter.
48+
49+
![doc_reporter_outputs](images/documentation_reporter_color.png)
50+
51+
52+
#XUnit reporter
53+
54+
Most of continuous integration servers (like Jenkins) are capable of consuming unit test execution results in [XUnit/JUnit](https://en.wikipedia.org/wiki/XUnit) format.
55+
The `ut_xunit_reporter` is producing outcomes as XUnit-compatible XML unit test report, that can be used by CI servers to display their custom reports and provide metrics (like tests execution trends).
56+
57+
Invocation of tests with XUnit reporter.
58+
59+
`exec ut.run(ut_xunit_reporter());`
60+
61+
The `ut_xunit_reporter` doesn't accept any arguments.
62+
63+
Example of xunit report integrated with [Jenkins CI](https://jenkins.io/)
64+
65+
![xunit_reporter_outputs](images/xunit_reporter_jenkins.png)
66+
67+
Example of failure report details
68+
69+
![xunit_reporter_outputs](images/xunit_reporter_jenkins_errors.png)
70+
71+
72+
#Teamcity reporter
73+
74+
[Teamcity](https://www.jetbrains.com/teamcity/) is a CI server by Jetbrains. The CI has it's own format of reporting that allows tracking of progress of a CI step/task as it executes.
75+
The format developed by Jetbrains is supported by utPLSQL with `ut_teamcity_reporter`.
76+
77+
Invocation of tests with Teamcity reporter.
78+
79+
`exec ut.run(ut_teamcity_reporter());`
80+
81+
The `ut_teamcity_reporter` doesn't accept any arguments.
82+
83+
Example of unit test report from Teamcity CI server.
84+
85+
![xunit_reporter_outputs](images/teamcity_report_example.png)
86+
87+
Example of failure report details
88+
89+
![xunit_reporter_outputs](images/teamcity_report_example_errors.png)
90+
91+
92+
# Coverage reporters
93+
94+
utPLSQL comes with a set of build-in coverage reporters. Have a look into the [coverage documentation](coverage.md) to learn more about them.
Lines changed: 105 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,105 @@
1-
#Running unit tests
2-
TODO
1+
utPLSQL framework provides two main entry points to run unit tests from within database:
2+
- `ut.run` procedures and functions
3+
- `ut_runner.run` procedures
4+
5+
Those two entry points differ in purpose and behavior.
6+
7+
# ut.run
8+
Package `ut` contains overloaded procedures and functions `run`.
9+
The `run` API is designed to be called directly by developer, when using IDE/SQL console to execute unit tests.
10+
The main benefit of using this API is it's simplicity.
11+
One-line call is enough to execute a set of tests form one or multiple schemes.
12+
13+
The **procedures** execute specified tests and produces outputs to DBMS_OUTPUT suing specified reporter
14+
The **functions** can only be used in SELECT statements. They execute specified tests and produce outputs as a pipelined data stream to be consumed by select satement.
15+
16+
## ut.run procedures
17+
18+
Examples:
19+
```sql
20+
alter session set current_schema=hr;
21+
begin
22+
ut.run();
23+
end;
24+
```
25+
Execute all tests in current schema (_HR_).
26+
27+
```sql
28+
begin
29+
ut.run('HR');
30+
end;
31+
```
32+
Execute all tests in specified schema (_HR_).
33+
34+
```sql
35+
begin
36+
ut.run('hr.test_apply_bonus');
37+
end;
38+
```
39+
Execute all tests from package _HR.TEST_APPLY_BONUS_.
40+
41+
```sql
42+
begin
43+
ut.run('hr.test_apply_bonus.bonus_cannot_be_negative');
44+
end;
45+
```
46+
Execute single test procedure _HR.TEST_APPLY_BONUS.BONUS_CANNOT_BE_NEGATIVE_.
47+
48+
```sql
49+
begin
50+
ut.run(ut_varcahr2_list('hr.test_apply_bonus','cust'));
51+
end;
52+
```
53+
Execute all tests from package _HR.TEST_APPLY_BONUS_ and all tests from schema _CUST_.
54+
Using a list of things to execute allows you to execute a fine-grained set of tests.
55+
56+
```sql
57+
begin
58+
ut.run('hr:com.my_org.my_project');
59+
end;
60+
```
61+
62+
Execute all tests from all packages that are on the _COM.MY_ORG.MY_PROJECT_ suitepath.
63+
Check the [annotations documentation](annotations.md) to find out about suitepaths and how they can be used to group test packages.
64+
65+
**Note:**
66+
`ut_documentation_reporter` is default reporter for all API's defined for running unit tests.
67+
68+
The `ut.run` procedures and functions accept `a_reporter` attribute that defines the reporter to be used in the run.
69+
You can execute any set of tests with any of the predefined reporters.
70+
71+
```sql
72+
begin
73+
ut.run('hr.test_apply_bonus', ut_xunit_reporter());
74+
end;
75+
```
76+
Execute all tests from package _HR.TEST_APPLY_BONUS_ and provide outputs to DBMS_OUTPUT using the XUnit reporter.
77+
78+
For details on build-in reporters look at [reporters documentation](reporters.md).
79+
80+
## ut.run functions
81+
82+
The `ut.run` functions provide exactly the same functionality as the procedures. You may use the same sets of parameters with both functions and procedures. The only difference is the output of the results.
83+
Functions provide outputs as pipelined stream and therefore need to be executed as select statements.
84+
85+
Example.
86+
```sql
87+
select * from table(ut.run('hr.test_apply_bonus', ut_xunit_reporter()));
88+
```
89+
90+
# ut_runner.run
91+
92+
The `ut_runner` provides API for integrating utPLSQL with other products. Maven, Jenkins, SQL Develper, PL/SQL Developer, TOAD and others can leverage this API to call utPLSQL.
93+
94+
The main difference as compared to `ut.run` API is that the `ut_runner.run` does not provide outputs.
95+
96+
`ut_runner.run` accepts multiple reporters. Each reporter produces outputs into a separate output (uniquely identified by output_id).
97+
Outputs of multiple reporters can be consumed in parallel. This allows for live reporting of test execution progress with threads and several database sessions.
98+
99+
The concept is pretty simple.
100+
101+
- in main thread (session), define the reporters to be used. Each reporter has it's output_id and so you need to extract and store those output_id's.
102+
- as a separate thread, start the `ut_runner.run` and pass reporters with previously defined output_id's
103+
- for each reporter start a separate thread and read outputs from `ut_output_buffer.get_lines` table function by providing the output_id defined in the main thread.
104+
105+

docs/userguide/ut_run-script.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
The `ut_run.sql` script is designed to allow invocation of utPLSQL with multiple reporters.
2+
It allows saving of outcomes into multiple output files.
3+
It also facilitates displaying on screen unit test results while the execution is still ongoing.
4+
Current limit of script parameters is 39
5+
6+
#Scrip invocation
7+
ut_run.sql user/password@database [-p=(ut_path|ut_paths)] [-c] [-f=format [-o=output] [-s] ...]
8+
9+
#Parameters
10+
```
11+
user - username to connect as
12+
password - password of the user
13+
database - database to connect to
14+
-p=ut_path(s)- A path or a comma separated list of paths to unit test to be executed.
15+
The path can be in one of the following formats:
16+
schema[.package[.procedure]]
17+
schema:suite[.suite[.suite][...]][.procedure]
18+
Both formats can be mixed in the comma separated list.
19+
If only schema is provided, then all suites owner by that schema (user) are executed.
20+
If -p is omitted, the current schema is used.
21+
-f=format - A reporter to be used for reporting.
22+
Available options:
23+
-f=ut_documentation_reporter
24+
A textual pretty-print of unit test results (usually use for console output)
25+
-f=ut_teamcity_reporter
26+
A teamcity Unit Test reporter, that can be used to visualize progress of test execution as the job progresses.
27+
-f=ut_xunit_reporter
28+
A XUnit xml format (as defined at: http://stackoverflow.com/a/9691131 and at https://gist.github.com/kuzuha/232902acab1344d6b578)
29+
Usually used by Continuous Integration servers like Jenkins/Hudson or Teamcity to display test results.
30+
If no -f option is provided, the ut_documentation_reporter will be used.
31+
32+
-o=output - file name to save the output provided by the reporter.
33+
If defined, the output is not displayed on screen by default. This can be changed with the -s parameter.
34+
If not defined, then output will be displayed on screen, even if the parameter -s is not specified.
35+
If more than one -o parameter is specified for one -f parameter, the last one is taken into consideration.
36+
-s - Forces putting output to to screen for a given -f parameter.
37+
-c - If specified, enables printing of test results in colors as defined by ANSICONSOLE standards
38+
```
39+
40+
Parameters -f, -o, -s are correlated. That is parameters -o and -s are defining outputs for -f.
41+
42+
Examples of invocation using sqlplus from command line:
43+
44+
`sqlplus /nolog @ut_run hr/hr@xe -p=hr_test -f=ut_documentation_reporter -o=run.log -s -f=ut_teamcity_reporter -o=teamcity.xml`
45+
46+
All Unit tests from schema/package "hr_test" will be be invoked with two reporters:
47+
- ut_documentation_reporter - will output to screen and save it's output to file "run.log"
48+
- ut_teamcity_reporter - will save it's output to file "teamcity.xml"
49+
50+
`sqlplus /nolog @ut_run hr/hr@xe`
51+
52+
All Unit tests from schema "hr" will be be invoked with ut_documentation_reporter as a format and the results will be printed to screen

readme.md

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,18 @@ utPLSQL version 3 is a complete rewrite of utPLSQL v2 from scratch.
1717
Version 2 still supports older versions of Oracle that are no longer available.
1818
The community that had developed on GitHub, decided that a new internal architecture was needed, from that version 3 was born.
1919

20-
We welcome new developers to join our community and contribute to the utPLSQL project.
20+
# Introduction
21+
utPLSQL is a Unit Testing framework for Oracle PL/SQL and SQL.
22+
The framework follows industry standards and best patterns of modern Unit Testing frameworks like [JUnit](http://junit.org/junit4/) and [RSpec](http://rspec.info/)
23+
2124

22-
Primary features:
23-
- Support for all basic scalar data-types
25+
# Primary features
26+
- Support for all basic scalar data-types except ROWID and RAW
2427
- Support for User Defined Object Types and Collections
2528
- Support for native cursors both strong and weak
26-
- Data-type aware testing
27-
- [Annotations](docs/userguide/annotations.md) based test definitions
28-
- Extensible [matchers](docs/userguide/expectations.md)
29+
- Data-type aware testing - number 1 is not equal to string '1'
30+
- [Annotations](docs/userguide/annotations.md) are used to define and configure tests
31+
- Extensible [expectations](docs/userguide/expectations.md)
2932
- Extensible reporting formats
3033
- Extensible output providers
3134
- Support for multi-reporting
@@ -43,6 +46,15 @@ __Download__
4346

4447
Published releases are available for download on the [utPLSQL GitHub Releases Page.](https://github.com/utPLSQL/utPLSQL/releases)
4548

49+
# Contributing to the project
50+
51+
We welcome new developers to join our community and contribute to the utPLSQL project.
52+
If you are interested in helping please read our [guide to contributing](docs/about/CONTRIBUTING.md)
53+
The best place to start is to read the documentation and get familiar existing with code base.
54+
A [slack chat](https://utplsql.slack.com/) is the place to go isf you want to talk with team members.
55+
To sign up to the chat use [this link](http://utplsql-slack-invite.herokuapp.com/)
56+
57+
4658
[__Authors__](docs/about/authors.md)
4759

4860
__Version 2 to Version 3 Comparison__
@@ -195,10 +207,6 @@ c:\my_work\>sqlplus /nolog @ut_run hr/hr@xe
195207
Will run all the suites in the current schema (hr) and provide documentation report into screen.
196208
Invoking this script will show the progress after each test.
197209

198-
# Contributing to the project
199-
200-
Community help on is always appreciated, if your interested in helping please read our [guide to contributing](docs/about/CONTRIBUTING.md)
201-
202210
__Project Directories__
203211

204212
* .travis - contains files needed for travis-ci integration

0 commit comments

Comments
 (0)