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

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
enhanced documentation
added not_to_be_true and not_to_be_false matchers
  • Loading branch information
Pazus committed May 6, 2017
commit b861d8251f6821ec61c05dd5fa7f318859733915
12 changes: 5 additions & 7 deletions docs/userguide/expectations.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Example of unit test procedure body with a single expectation.
```sql
begin
ut.expect( 'the tested value' ).to_equal('the expected value');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we keep both styles in the documentation for completeness?

ut.expect( 'the tested value' ).to_( equal('the expected value') );
end;
```

Expand All @@ -19,13 +20,12 @@ Pseudo-code:
ut.expect( a_actual {data-type} ).not_to( {matcher} );
```

Most of the matchers have shortcuts like:
All matchers have shortcuts like:
```sql
ut.expect( a_actual {data-type} ).to_{matcher};
ut.expect( a_actual {data-type} ).not_to{matcher};
```


# Matchers
utPLSQL provides following matchers to perform checks on the expected and actual values.
- `be_between`
Expand Down Expand Up @@ -183,8 +183,6 @@ end;
```
The `a_nulls_are_equal` parameter decides on the behavior of `null=null` comparison (**this comparison by default is true!**)

There are no shortcuts for `not_to_equal`, so use `not_to (equal(...))`

### Comparing cursors

The `equal` matcher accepts additional parameter `a_exclude varchar2` or `a_exclude ut_varchar2_list`, when used to compare `cursor` data.
Expand Down Expand Up @@ -270,7 +268,7 @@ create or replace package body test_get_events is
ut.reset_nls();

ut.expect(l_actual).to_equal(l_expected);
ut.expect(l_actual).not_to( equal(l_expected_bad_date) );
ut.expect(l_actual).not_to_equal(l_expected_bad_date);
end;

end;
Expand Down Expand Up @@ -385,9 +383,9 @@ end;

Syntax of check for matcher evaluating to false:
```sql
begin
ut.expect( a_actual {data-type} ).not_to( {matcher} );
begin
ut.expect( a_actual {data-type} ).not_to_{matcher};
ut.expect( a_actual {data-type} ).not_to( {matcher} );
end;
```

Expand Down
12 changes: 12 additions & 0 deletions source/expectations/ut_expectation_boolean.tpb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ create or replace type body ut_expectation_boolean as
ut_utils.debug_log('ut_expectation_boolean.not_to_equal(self in ut_expectation_boolean, a_expected boolean, a_nulls_are_equal boolean := null)');
self.not_to( ut_equal(a_expected, a_nulls_are_equal) );
end;

member procedure not_to_be_true(self in ut_expectation_boolean) is
begin
ut_utils.debug_log('ut_expectation_boolean.not_to_be_true(self in ut_expectation_boolean)');
self.not_to( ut_be_true() );
end;

member procedure not_to_be_false(self in ut_expectation_boolean) is
begin
ut_utils.debug_log('ut_expectation_boolean.not_to_be_false(self in ut_expectation_boolean)');
self.not_to( ut_be_false() );
end;

end;
/
4 changes: 3 additions & 1 deletion source/expectations/ut_expectation_boolean.tps
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ create or replace type ut_expectation_boolean under ut_expectation(
member procedure to_be_true(self in ut_expectation_boolean),
member procedure to_be_false(self in ut_expectation_boolean),

overriding member procedure not_to_equal(self in ut_expectation_boolean, a_expected boolean, a_nulls_are_equal boolean := null)
overriding member procedure not_to_equal(self in ut_expectation_boolean, a_expected boolean, a_nulls_are_equal boolean := null),
member procedure not_to_be_true(self in ut_expectation_boolean),
member procedure not_to_be_false(self in ut_expectation_boolean)
)
/