Skip to content

Commit 482d7d7

Browse files
authored
Merge pull request #355 from john-otoole/documentation-fixes-part2
A few more minor documentation fixes
2 parents dd2a492 + d9b9446 commit 482d7d7

2 files changed

Lines changed: 56 additions & 56 deletions

File tree

docs/userguide/expectations.md

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Validation of the code under test (the tested logic of procedure/function etc.) is performed by comparing the actual data against the expected data.
44
To achieve that, we use a combination of expectation and matcher to perform the check on the data.
55

6-
Example of unit test procedure body.
6+
Example of a unit test procedure body.
77
```sql
88
begin
99
ut.expect( 'the tested value' ).to_( equal('the expected value') );
@@ -12,7 +12,7 @@ end;
1212

1313
Expectation is a set of the expected value(s), actual values(s) and the matcher(s) to run on those values.
1414

15-
Matcher is defining the comparison operation to be performed on expected and actual values.
15+
Matcher defines the comparison operation to be performed on expected and actual values.
1616
Pseudo-code:
1717
```
1818
ut.expect( a_actual {data-type} ).to_( {matcher} );
@@ -26,7 +26,7 @@ All matchers have shortcuts like:
2626
```
2727

2828
# Matchers
29-
utPLSQL provides following matchers to perform checks on the expected and actual values.
29+
utPLSQL provides the following matchers to perform checks on the expected and actual values.
3030

3131
- `be_between`
3232
- `be_empty`
@@ -57,7 +57,7 @@ end;
5757
```
5858

5959
## be_empty
60-
Unary matcher that validates if the provided data-set is empty.
60+
Unary matcher that validates if the provided dataset is empty.
6161

6262
Usage:
6363
```sql
@@ -86,7 +86,7 @@ end;
8686
```
8787

8888
## be_greater_or_equal
89-
Allows to check if the actual value is greater or equal than the expected.
89+
Checks if the actual value is greater or equal than the expected.
9090

9191
Usage:
9292
```sql
@@ -98,7 +98,7 @@ end;
9898
```
9999

100100
## be_greater_than
101-
Allows to check if the actual value is greater than the expected.
101+
Checks if the actual value is greater than the expected.
102102

103103
Usage:
104104
```sql
@@ -110,7 +110,7 @@ end;
110110
```
111111

112112
## be_less_or_equal
113-
Allows to check if the actual value is less or equal than the expected.
113+
Checks if the actual value is less or equal than the expected.
114114

115115
Usage:
116116
```sql
@@ -122,7 +122,7 @@ end;
122122
```
123123

124124
## be_less_than
125-
Allows to check if the actual value is less than the expected.
125+
Checks if the actual value is less than the expected.
126126

127127
Usage:
128128
```sql
@@ -148,7 +148,7 @@ begin
148148
end;
149149
```
150150

151-
Parameters `a_mask` and `a_escape_char` represent a valid parameters of the [Oracle like function](https://docs.oracle.com/database/121/SQLRF/conditions007.htm#SQLRF52142)
151+
Parameters `a_mask` and `a_escape_char` represent valid parameters of the [Oracle LIKE condition](https://docs.oracle.com/database/121/SQLRF/conditions007.htm#SQLRF52142)
152152

153153

154154
## be_not_null
@@ -178,7 +178,7 @@ end;
178178
```
179179

180180
## be_true
181-
Unary matcher that validates if the provided value is false.
181+
Unary matcher that validates if the provided value is true.
182182
- `boolean`
183183

184184
Usage:
@@ -192,10 +192,9 @@ end;
192192

193193
## equal
194194

195-
The equal matcher is a very restrictive matcher. It only returns true, if compared data-types are the same.
196-
That means, that comparing varchar2 to a number will fail even if the varchar2 contains the same number.
197-
This matcher is designed to capture changes of data-type, so that if you expect your variable to be number and is now something else,
198-
the test will fail and give you early indication of potential problem.
195+
The equal matcher is a very restrictive matcher. It only returns true if the compared data-types are the same.
196+
That means that comparing varchar2 to a number will fail even if the varchar2 contains the same number.
197+
This matcher is designed to capture changes of data-type, so that if you expect your variable to be a number and it is now some other type, the test will fail and give you early indication of a potential problem.
199198

200199
Usage:
201200
```sql
@@ -210,16 +209,17 @@ begin
210209
ut.expect( a_actual => y ).to_( equal( a_expected => x, a_nulls_are_equal => true ) );
211210
end;
212211
```
213-
The `a_nulls_are_equal` parameter decides on the behavior of `null=null` comparison (**this comparison by default is true!**)
212+
The `a_nulls_are_equal` parameter controls the behavior of a `null=null` comparison (**this comparison by default is true!**)
214213

215214
### Comparing cursors
216215

217-
The `equal` matcher accepts additional parameter `a_exclude varchar2` or `a_exclude ut_varchar2_list`, when used to compare `cursor` data.
218-
Those parameters allow passing a list of column names to exclude from data comparison. The list can be a comma separated `varchar2` list or a `ut_varchar2_list` collection.
219-
The column names accepted by parameter are **case sensitive** and cannot be quoted.
220-
If `a_exclude` parameter is not specified, all columns are included.
216+
The `equal` matcher accepts an additional parameter `a_exclude varchar2` or `a_exclude ut_varchar2_list`, when used to compare `cursor` data.
217+
218+
These parameters enable a list of column names to be passed for exclusion from the data comparison. The list can be a comma separated `varchar2` list or a `ut_varchar2_list` collection.
219+
The column names accepted by the parameter are **case sensitive** and cannot be quoted.
220+
If the `a_exclude` parameter is not specified, all columns are included.
221221
If a column to be excluded does not exist, the column cannot be excluded and it's name is simply ignored.
222-
It is useful when testing cursors containing data that is beyond our control (like default or trigger/procedure generated sysdate values on columns).
222+
This is useful when testing cursors containing data that is beyond our control (like default or trigger/procedure generated sysdate values on columns).
223223

224224
```sql
225225
procedure test_cursors_skip_columns is
@@ -236,22 +236,22 @@ end;
236236

237237
There is a great article by Tim Hall on [using the TABLE Operator with Locally Defined Types in PL/SQL](https://oracle-base.com/articles/12c/using-the-table-operator-with-locally-defined-types-in-plsql-12cr1).
238238
If you are on Oracle 12c, you can benefit from this feature to make comparison of PLSQL records and tables super-simple in utPLSQL.
239-
You can use the feature described in article to convert PLSQL records and collection types to cursors. Complex cursor data can then be compared in utPLQL.
239+
You can use the feature described in the article to convert PLSQL records and collection types to cursors. Complex cursor data can then be compared in utPLQL.
240240

241241

242242
### Comparing cursor data containing DATE fields
243243

244244
**Important note**
245245

246-
utPLSQL uses XMLType internally to represent rows of the cursor data. This is by far most flexible and allows comparison of cursors containing LONG, CLOB, BLOB, user defined types and even nested cursors.
246+
utPLSQL uses XMLType internally to represent rows of the cursor data. This is by far the most flexible method and allows comparison of cursors containing LONG, CLOB, BLOB, user defined types and even nested cursors.
247247
Due to the way Oracle handles DATE data type when converting from cursor data to XML, utPLSQL has no control over the DATE formatting.
248-
The NLS_DATE_FORMAT setting from the moment the cursor was opened decides ont the formatting of dates used for cursor data comparison.
249-
By default, Oracle NLS_DATE_FORMAT is timeless, so data of DATE datatype, will be compared ignoring the time part of it.
248+
The NLS_DATE_FORMAT setting from the moment the cursor was opened determines the formatting of dates used for cursor data comparison.
249+
By default, Oracle NLS_DATE_FORMAT is timeless, so data of DATE datatype, will be compared ignoring the time component.
250250

251251
You should use procedures `ut.set_nls`, `ut.reset_nls` around cursors that you want to compare in your tests.
252-
This way, the DATE data in cursors will get properly formatted for comparison using date-time format.
252+
This way, the DATE data in cursors will be properly formatted for comparison using date-time format.
253253

254-
The example below makes use of `ut.set_nls`, `ut.reset_nls`, so that date in `l_expected` and `l_actual` is compared using date-time formatting.
254+
The example below makes use of `ut.set_nls`, `ut.reset_nls`, so that the date in `l_expected` and `l_actual` is compared using date-time formatting.
255255
```sql
256256
create table events (
257257
description varchar2(4000),
@@ -323,7 +323,7 @@ drop package test_get_events;
323323

324324
### Comparing user defined types and collections
325325

326-
The `anydata` data type is used to compare user defined object and collections.
326+
The `anydata` data type is used to compare user defined objects and collections.
327327

328328
Example:
329329
```sql
@@ -368,7 +368,7 @@ end;
368368
/
369369
```
370370

371-
This test will fail as the `v_acutal` is not equal `v_expected`.
371+
This test will fail as `v_actual` is not equal `v_expected`.
372372

373373
## match
374374
Validates that the actual value is matching the expected regular expression.
@@ -384,13 +384,13 @@ begin
384384
end;
385385
```
386386

387-
Parameters `a_pattern` and `a_modifiers` represent a valid regexp pattern accepted by [Oracle regexp_like function](https://docs.oracle.com/database/121/SQLRF/conditions007.htm#SQLRF00501)
387+
Parameters `a_pattern` and `a_modifiers` represent a valid regexp pattern accepted by [Oracle REGEXP_LIKE condition](https://docs.oracle.com/database/121/SQLRF/conditions007.htm#SQLRF00501)
388388

389389

390390

391391
# Supported data types
392392

393-
Below matrix illustrates the data types supported by different matchers.
393+
The matrix below illustrates the data types supported by different matchers.
394394

395395
| | be_between | be_empty | be_false | be_greater_than | be_greater_or_equal | be_less_or_equal | be_less_than | be_like | be_not_null | be_null | be_true | equal | match |
396396
|:------------------------------|:----------:|:--------:|:--------:|:---------------:|:-------------------:|:----------------:|:------------:|:-------:|:-----------:|:-------:|:-------:|:-----:|:-----:|
@@ -411,17 +411,17 @@ Below matrix illustrates the data types supported by different matchers.
411411

412412

413413
# Negating a matcher
414-
Expectations provide a very convenient way to perform a check on negated matcher.
414+
Expectations provide a very convenient way to perform a check on a negated matcher.
415415

416-
Syntax of check for matcher evaluating to true:
416+
Syntax to check for matcher evaluating to true:
417417
```sql
418418
begin
419419
ut.expect( a_actual {data-type} ).to_{matcher};
420420
ut.expect( a_actual {data-type} ).to_( {matcher} );
421421
end;
422422
```
423423

424-
Syntax of check for matcher evaluating to false:
424+
Syntax to check for matcher evaluating to false:
425425
```sql
426426
begin
427427
ut.expect( a_actual {data-type} ).not_to_{matcher};
@@ -438,5 +438,5 @@ begin
438438
ut.expect( null ).not_to( be_true() );
439439
end;
440440
```
441-
Since NULL is neither true not it is not true, both expectations will report failure.
441+
Since NULL is neither *true* nor *not true*, both expectations will report failure.
442442

docs/userguide/getting-started.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Getting started with TDD and utPLSQL
22

3-
utPLSQL is designed in a way that allows you follow
3+
utPLSQL is designed in a way that allows you to follow
44
[Test Driven Development (TDD)](https://en.wikipedia.org/wiki/Test-driven_development) software development process.
55

66
Below is an example of building a simple function with TDD.
77

8-
# Gather requirement
8+
# Gather requirements
99

10-
We have a requirement to build a function that will return a substring of a string that is passed to the function.
10+
We have a requirement to build a function that will return a substring of a string that is passed to the function.
1111

1212
The function should accept three parameters:
1313

@@ -41,7 +41,7 @@ Finished in .451423 seconds
4141
0 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)
4242
```
4343

44-
## Define specification for test
44+
## Define specification for the test
4545

4646
```sql
4747
create or replace package test_betwnstr as
@@ -72,7 +72,7 @@ Finished in .509673 seconds
7272
1 tests, 0 failed, 1 errored, 0 disabled, 0 warning(s)
7373
```
7474

75-
Well our test is failing as package specification requires body.
75+
Well our test is failing as the package specification requires a body.
7676

7777
## Define body of first test
7878

@@ -105,10 +105,10 @@ Finished in .415851 seconds
105105
1 tests, 0 failed, 1 errored, 0 disabled, 0 warning(s)
106106
```
107107

108-
Our test is failing, as the test suite package body is invalid.
108+
Our test is failing as the test suite package body is invalid.
109109
Looks like we need to define the function we want to test.
110110

111-
# Implement code to fulfill requirement
111+
# Implement code to fulfill the requirement
112112

113113
## Define tested function
114114

@@ -138,12 +138,12 @@ Finished in .375178 seconds
138138
1 tests, 1 failed, 0 errored, 0 disabled, 0 warning(s)
139139
```
140140

141-
So now we see that our test works but the function does not return expected results.
142-
Let us fix this and continue form here.
141+
So now we see that our test works but the function does not return the expected results.
142+
Let us fix this and continue from here.
143143

144144
## Fix the tested function
145145

146-
The function returned string one character short, so we need to add 1 to the substr parameter.
146+
The function returned a string one character short, so we need to add 1 to the substr parameter.
147147

148148
```sql
149149
create or replace function betwnstr( a_string varchar2, a_start_pos integer, a_end_pos integer ) return varchar2
@@ -169,15 +169,15 @@ So our test is now passing, great!
169169

170170
# Refactor
171171

172-
Once our tests are passing, we can safely refactor (restructure) the code as we have safety harness
173-
in place to assure that after the restructuring and cleanup of the code, everything is still working.
172+
Once our tests are passing, we can safely refactor (restructure) the code as we have a safety harness
173+
in place to ensure that after the restructuring and cleanup of the code, everything is still working.
174174

175-
One thing worth mentioning is that refactoring of tests is as important as refactoring of code. Maintainability of both is similarly important.
175+
One thing worth mentioning is that refactoring of tests is as important as refactoring of code. Maintainability of both is equally important.
176176

177177
# Further requirements
178178

179-
It seems like our work is done. We have function that returns a substring from start position to end position.
180-
As we move, through process of adding tests, it's very important to think about edge cases.
179+
It seems like our work is done. We have a function that returns a substring from start position to end position.
180+
As we move through the process of adding tests, it's very important to think about edge cases.
181181

182182
Here is a list of edge cases for our function:
183183

@@ -190,12 +190,12 @@ Here is a list of edge cases for our function:
190190
- start position is negative
191191
- end position is negative
192192

193-
We should define expected behavior for each of edge cases.
194-
Once defined we can start implementing tests for those behaviors and adjust tested function to meet requirements specified in tests.
193+
We should define expected behavior for each of these edge cases.
194+
Once defined we can start implementing tests for those behaviors and adjust the tested function to meet the requirements specified in the tests.
195195

196196
## Add test for additional requirement
197197

198-
New requirement was added:
198+
A new requirement was added:
199199
Start position zero - should be treated as start position one
200200

201201
```sql
@@ -248,9 +248,9 @@ Finished in .232584 seconds
248248

249249
Looks like our function does not work as expected for zero start position.
250250

251-
## Implementing requirement
251+
## Implementing the requirement
252252

253-
Lets fix our function so that the new requirement is met
253+
Let's fix our function so that the new requirement is met
254254

255255
```sql
256256
create or replace function betwnstr( a_string varchar2, a_start_pos integer, a_end_pos integer ) return varchar2
@@ -281,11 +281,11 @@ Great! We have made some visible progress.
281281

282282
## Refactoring
283283

284-
When all tests are passing we can proceed with safe cleanup of our code.
284+
When all tests are passing we can proceed with a safe cleanup of our code.
285285

286286
The function works well, but we use the `return` twice, which is not the best coding practice.
287287

288-
Alternative implementation could be cleaner.
288+
An alternative implementation could be cleaner.
289289
```sql
290290
create or replace function betwnstr( a_string varchar2, a_start_pos integer, a_end_pos integer ) return varchar2
291291
is

0 commit comments

Comments
 (0)