|
6 | 6 | [](https://twitter.com/utPLSQL) |
7 | 7 |
|
8 | 8 | ---------- |
9 | | -Version 3 is a complete rewrite of utPLSQL from scratch. Version 2 still supports older versions of Oracle that are no longer available. This has lead to difficult to maintain code. Yet many developers wanted to take it to the next level. The community that had developed on GitHub, decided that a new internal architecture was needed, from that version 3 was born. Currently version 3 is not complete and is not ready for a production environment as the API is not stable and changing. However it is quickly taking shape. We welcome new developers to join our community and help utPLSQL grow. |
10 | | - |
11 | | -Primary Goals: |
12 | | - - Easier to maintain |
13 | | - - Only supports versions of Oracle under [Extend Support](http://www.oracle.com/us/support/library/lifetime-support-technology-069183.pdf) (Currently 11.2, and 12.1) |
14 | | - - API is documented in the code where possible. |
15 | | - - Robust and vibrant assertion library. |
16 | | - - Support for Code Coverage |
17 | | - - Extensible API |
18 | | - - Published upgrade/conversion path from version 2. |
19 | | - - Easily called from current PL/SQL development tools |
20 | | - - More permissive License to allow vendors easier ability to integrate utPLSQL. |
| 9 | +utPLSQL version 3 is a complete rewrite of utPLSQL v2 from scratch. |
| 10 | +Version 2 still supports older versions of Oracle that are no longer available. |
| 11 | +The community that had developed on GitHub, decided that a new internal architecture was needed, from that version 3 was born. |
| 12 | + |
| 13 | +We welcome new developers to join our community and contribute to the utPLSQL project. |
| 14 | + |
| 15 | +Primary features: |
| 16 | + - Support for all basic scalar data-types |
| 17 | + - Support for User Defined Object Types and Collections |
| 18 | + - Support for native cursors both strong and weak |
| 19 | + - Data-type aware testing |
| 20 | + - [Annotations](docs/userguide/annotations.md) based test definitions |
| 21 | + - Extensible [matchers](docs/userguide/expectations.md) |
| 22 | + - Extensible reporting formats |
| 23 | + - Extensible output providers |
| 24 | + - Support for multi-reporting |
| 25 | + - Code coverage reporting (with different formats) |
| 26 | + - Runtime reporting of test execution progress |
| 27 | + - Well-defined API |
| 28 | + - Easy to call from current PL/SQL development tools |
| 29 | + - More permissive License to allow vendors to integrate utPLSQL without violation of license |
| 30 | + - Published upgrade/conversion path from version 2 ( TODO ) |
| 31 | + |
| 32 | +Requirements: |
| 33 | + - Version of Oracle under [Extend Support](http://www.oracle.com/us/support/library/lifetime-support-technology-069183.pdf) (Currently 11.2 and above) |
21 | 34 |
|
22 | 35 | __Version 2 to Version 3 Comparison__ |
23 | 36 |
|
@@ -81,84 +94,103 @@ sqlplus admin/admins_password@xe @@install_headless.sql |
81 | 94 |
|
82 | 95 | For detailed instructions on other install options see the [Install Guide](docs/userguide/install.md) |
83 | 96 |
|
84 | | -# Annotations |
| 97 | +# Example test package |
85 | 98 |
|
86 | | -Annotations provide a way to configure tests and suites in a declarative way similar to modern OOP languages. |
87 | | -The annotation list is based on moder testing framework such as jUnit 5, RSpec. |
| 99 | +The below test package is a fully-functional Unit Test package for testing a function `betwnstr`. |
| 100 | +Package specification is annotated with special comments ([annotations](docs/userguide/annotations.md)). |
| 101 | +Annotations define that a package is a unit test suite, they also allow defining a description for the suite as well as the test itself. |
| 102 | +Package body consists of procedures containing unit test code. To validate [an expectation](docs/userguide/expectations.md) in test, use `ut.expect( actual_data ).to_( ... )` syntax. |
88 | 103 |
|
89 | | -Annotations allow to configure test infrastructure in a declarative way without anything stored in tables or config files. The framework runner scans the schema for all the suitable annotated packages, automatically configures suites, forms hierarchy from then and executes them. |
90 | 104 |
|
91 | | -# Example of annotated package |
92 | | -``` |
93 | | -create or replace package test_pkg is |
| 105 | +```sql |
| 106 | +create or replace package test_between_string as |
| 107 | + |
| 108 | + -- %suite(Between string function) |
94 | 109 |
|
95 | | - -- %suite(Name of suite) |
96 | | - -- %suitepath(all.globaltests) |
| 110 | + -- %test(Returns substring from start position to end position) |
| 111 | + procedure normal_case; |
97 | 112 |
|
98 | | - -- %beforeall |
99 | | - procedure globalsetup; |
| 113 | + -- %test(Returns substring when start position is zero) |
| 114 | + procedure zero_start_position; |
100 | 115 |
|
101 | | - -- %afterall |
102 | | - procedure global_teardown; |
| 116 | + -- %test(Returns string until end if end position is greater than string length) |
| 117 | + procedure big_end_position; |
103 | 118 |
|
104 | | - /* Such comments are allowed */ |
| 119 | + -- %test(Returns null for null input string value) |
| 120 | + procedure null_string; |
| 121 | +end; |
| 122 | +/ |
105 | 123 |
|
106 | | - -- %test |
107 | | - -- %displayname(Name of test1) |
108 | | - procedure test1; |
| 124 | +create or replace package body test_between_string as |
109 | 125 |
|
110 | | - -- %test(Name of test2) |
111 | | - -- %beforetest(setup_test1) |
112 | | - -- %aftertest(teardown_test1) |
113 | | - procedure test2; |
| 126 | + procedure normal_case is |
| 127 | + begin |
| 128 | + ut.expect( betwnstr( '1234567', 2, 5 ) ).to_equal('2345') ); |
| 129 | + end; |
114 | 130 |
|
115 | | - -- %test |
116 | | - -- %displayname(Name of test3) |
117 | | - -- %disable |
118 | | - procedure test3; |
119 | | - |
120 | | - -- %test(Name of test4) |
121 | | - -- %rollback(manual) |
122 | | - procedure test4; |
| 131 | + procedure zero_start_position is |
| 132 | + begin |
| 133 | + ut.expect( betwnstr( '1234567', 0, 5 ) ).to_( equal('12345') ); |
| 134 | + end; |
123 | 135 |
|
124 | | - procedure setup_test1; |
| 136 | + procedure big_end_position is |
| 137 | + begin |
| 138 | + ut.expect( betwnstr( '1234567', 0, 500 ) ).to_( equal('1234567') ); |
| 139 | + end; |
125 | 140 |
|
126 | | - procedure teardown_test1; |
| 141 | + procedure null_string is |
| 142 | + begin |
| 143 | + ut.expect( betwnstr( null, 2, 5 ) ).to_( be_null ); |
| 144 | + end; |
127 | 145 |
|
128 | | - -- %beforeeach |
129 | | - procedure setup; |
| 146 | +end; |
| 147 | +/ |
| 148 | +``` |
130 | 149 |
|
131 | | - -- %aftereach |
132 | | - procedure teardown; |
133 | 150 |
|
134 | | -end test_pkg; |
| 151 | +# Running tests |
| 152 | + |
| 153 | +To execute using IDE ()TOAD/SQLDeveloper/PLSQLDeveloper/other) just run the following. |
| 154 | +```sql |
| 155 | +begin |
| 156 | + ut_runner.run(); |
| 157 | +end; |
| 158 | +/ |
135 | 159 | ``` |
| 160 | +Will run all the suites in the current schema and provide documentation report using dbms_output |
136 | 161 |
|
137 | | -#Annotations meaning |
| 162 | +``` |
| 163 | +Between string function |
| 164 | + Returns substring from start position to end position |
| 165 | + Returns substring when start position is zero |
| 166 | + Returns string until end if end position is greater than string length |
| 167 | + Returns null for null input string value |
| 168 | +
|
| 169 | +Finished in .036027 seconds |
| 170 | +4 tests, 0 failures |
| 171 | +``` |
| 172 | + |
| 173 | +To execute your tests from command line, you will need a oracle sql client like SQLPlus or [SQLcl](http://www.oracle.com/technetwork/developer-tools/sqlcl/overview/index.html) |
| 174 | +You may benefit from using the [ut_run.sql](client_source/sqlplus/ut_run.sql) to execute your tests if you want to achieve one of the following: |
| 175 | +* see the progress of test execution for long-running tests |
| 176 | +* have output to screen with one output format (text) and at the same time have output to file in other format (xunit) |
138 | 177 |
|
139 | | -| Annotation |Level| Describtion | |
140 | | -| --- | --- | --- | |
141 | | -| `%suite(<description>)` | Package | Marks package to be a suite of tests This way all testing packages might be found in a schema. Optional schema discription can by provided, similar to `%displayname` annotation. | |
142 | | -| `%suitepath(<path>)` | Package | Similar to java package. The annotation allows logical grouping of suites into hierarcies. | |
143 | | -| `%displayname(<description>)` | Package/procedure | Human-familiar describtion of the suite/test. Syntax is based on jUnit annotation: `%displayname(Name of the suite/test)` | |
144 | | -| `%test(<description>)` | Procedure | Denotes that a method is a test method. Optional test discription can by provided, similar to `%displayname` annotation. | |
145 | | -| `%beforeall` | Procedure | Denotes that the annotated procedure should be executed once before all elements of the current suite. | |
146 | | -| `%afterall` | Procedure | Denotes that the annotated procedure should be executed once after all elements of the current suite. | |
147 | | -| `%beforeeach` | Procedure | Denotes that the annotated procedure should be executed before each `%test` method in the current suite. | |
148 | | -| `%aftereach` | Procedure | Denotes that the annotated procedure should be executed after each `%test` method in the current suite. | |
149 | | -| `%beforetest(<procedure_name>)` | Procedure | Denotes that mentioned procedure should be executed before the annotated `%test` procedure. | |
150 | | -| `%aftertest(<procedure_name>)` | Procedure | Denotes that mentioned procedure should be executed after the annotated `%test` procedure. | |
151 | | -| `%rollback(<type>)` | Package/procedure | Configure transaction control behaviour (type). Supported values: `auto`(default) - rollback to savepoint (before the test/suite setup) is issued after each test/suite teardown; `manual` - rollback is never issued automatically. Property can be overridden for child element (test in suite) | |
152 | | -| `%disable` | Package/procedure | Used to disable a suite or a test | |
| 178 | +Example: |
| 179 | +``` |
| 180 | +c:\my_work\>sqlplus /nolog @ut_run hr/hr@xe |
| 181 | +``` |
| 182 | +Will run all the suites in the current schema (hr) and provide documentation report into screen. |
| 183 | +Invoking this script will show the progress after each test. |
153 | 184 |
|
154 | 185 |
|
155 | 186 | __Primary Directories__ |
156 | 187 |
|
157 | 188 | * .travis - contains files needed for travis-ci integration |
| 189 | +* client_source - Sources to be used on the client-side. Developer workstation or CI platform to run the tests. |
| 190 | +* development - Set of useful scripts and utilities for development and debugging of utPLSQL |
158 | 191 | * docs - Markdown version of the documentation |
159 | 192 | * examples - contains example unit tests. |
160 | | -* source - contains the code utPLSQL |
161 | | -* lib - 3rd party libraries that are required for source. |
| 193 | +* source - contains the installation code for utPLSQL |
162 | 194 | * tests - contains the tests written to test utPLSQL |
163 | 195 |
|
164 | 196 |
|
|
0 commit comments