-
Notifications
You must be signed in to change notification settings - Fork 189
Updated documentation. #164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| # Concept of expectation and matcher | ||
|
|
||
| Validation of the code under test (the tested logic of procedure/function etc.) is performed by comparing the actual data against the expected data. | ||
| To do that we use concept of expectation and a matcher to perform the check on the data. | ||
|
|
||
| It's best to give an example to get an idea what is what | ||
| ```sql | ||
| begin | ||
| ut.expect( 'the tested value' ).to_( equal('the expected value') ); | ||
| end; | ||
| ``` | ||
|
|
||
| Expectation is a set of the expected value(s), actual values(s) and the matcher(s) to run on those values. | ||
|
|
||
| Matcher is defining the comparison operation to be performed on expected and actual values. | ||
|
|
||
| # List of currently build-in matchers | ||
| - `match` | ||
| - `equal` | ||
| - `be_true` | ||
| - `be_null` | ||
| - `be_not_null` | ||
| - `be_like` | ||
| - `be_less_than` | ||
| - `be_less_or_equal` | ||
| - `be_greater_than` | ||
| - `be_greater_or_equal` | ||
| - `be_false` | ||
| - `be_between` | ||
|
|
||
| ## match | ||
| Allows regexp_like validations to be executed against the following datatypes: | ||
| - `clob` | ||
| - `varchar2` | ||
|
|
||
| Usage: | ||
| ```sql | ||
| ut.expect( a_actual ).to_( match( a_pattern in varchar2, a_modifiers in varchar2 := null) ) | ||
| ``` | ||
|
|
||
| Parameters `a_pattern` and `a_modifiers` represent a valid regexp pattern accepted by [Oracle regexp_like function](https://docs.oracle.com/cd/E11882_01/server.112/e41084/conditions007.htm#SQLRF00501) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| ## equal | ||
|
|
||
| The equal matcher is a very restrictive matcher. | ||
| It only returns true, if compared data-types. | ||
| That means, that comparing varchar2 to a number will fail even if the varchar2 contains the same number. | ||
| 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, | ||
| the test will fail and give you early indication of potential problem. | ||
|
|
||
| Usage: | ||
| ```sql | ||
| ut.expect( a_actual ).to_( equal( a_expected {mulitple data-types}, a_nulls_are_equal boolean := null) ) | ||
| ``` | ||
|
|
||
|
|
||
| The equal matcher accepts a_expected of following data-types. | ||
| - `anydata` | ||
| - `blob` | ||
| - `boolean` | ||
| - `clob` | ||
| - `date` | ||
| - `number` | ||
| - `sys_refcursor` | ||
| - `timestamp_unconstrained` | ||
| - `timestamp_tz_unconstrained` | ||
| - `timestamp_ltz_unconstrained` | ||
| - `varchar2` | ||
| - `yminterval_unconstrained` | ||
| - `dsinterval_unconstrained` | ||
|
|
||
| The second parameter decides on the behavior of `null=null` comparison (**this comparison by default is true!**) | ||
|
|
||
|
|
||
| A test procedure will contain one or more checks to verify the the test performed as expected. These checks are called assertion. utPLSQL provides a robust and extensible assertion library. | ||
|
|
||
|
|
||
| TODO: Finish Expectations concepts | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we use
to_( equalsyntax in examples and notto_equal?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I though
to_equalis the primary syntax to use andto_( equalis a more general formThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
to_()is a base syntax for extensible matchers and theto_equal()is just a wrapper.Not all matcher have wrappers for them and getting developers familiar with the
to_syntax seemed like a good idea.