You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/userguide/advanced_data_comparison.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ utPLSQL expectations incorporates advanced data comparison options when comparin
6
6
- object type
7
7
- nested table and varray
8
8
9
-
Advanced data-comparison options are available for the [`equal`](expectations.md#equal) and [`include/ contain`](expectations.md#include) matcher.
9
+
Advanced data-comparison options are available for the [`equal`](expectations.md#equal) and [`include/ contain`](expectations.md#include) matcher.
10
10
11
11
## Syntax
12
12
@@ -27,7 +27,7 @@ Advanced data-comparison options are available for the [`equal`](expectations.md
27
27
-`exclude(a_items varchar2)` - item or comma separated list of items to exclude
28
28
-`include(a_items ut_varchar2_list)` - table of items to include
29
29
-`exclude(a_items ut_varchar2_list)` - table of items to exclude
30
-
-`unordered` - perform compare on unordered set of data, return only missing or actual ***not supported for `include / contain`***
30
+
-`unordered` - perform compare on unordered set of data, return only missing or actual,***not supported for `include / contain`*** , as alternative `join_by` can be used
31
31
-`join_by(a_columns varchar2)` - columns or comma separated list of columns to join two cursors by
32
32
-`join_by(a_columns ut_varchar2_list)` - table of columns to join two cursors by
Copy file name to clipboardExpand all lines: docs/userguide/expectations.md
+57-10Lines changed: 57 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -437,15 +437,17 @@ To change the behavior of `NULL = NULL` comparison pass the `a_nulls_are_equal =
437
437
438
438
This matcher supports only cursor comparison. It check if the give set contain all values from given subset.
439
439
440
-
Test using this matcher behaves similar to `equal` in respect that it succeeds only when the compared data-types are exactly the same.
440
+
when comparing data using `include / contain` matcher, the data-types of columns for compared cursors must be exactly the same.
441
441
442
442
The matcher supports all advanced comparison options as `equal` e.g. include , exclude, join_by.
443
443
444
-
The matcher will be successful only when all of the values in expected results are part of actual set.
444
+
The matcher is successful when all of the values from expected results are included in actual data set.
445
445
446
-
In situation where the duplicate is present in expected set we would also expect matching number of occurrences in actual set for matcher to be success.
446
+
The matcher will cause a test to fail if any of expected values are not included in actual data set.
@@ -474,11 +476,56 @@ Will result in failure message
474
476
Missing: <ROW><RN>1</RN></ROW>
475
477
```
476
478
479
+
When duplicate rows are present in expected data set, actual data set must also include the same amount of duplicate.
480
+
481
+
*Example 2.*
477
482
478
483
479
-
Similar negated `not_to_include`/ `not_to_contain` will be successful only when none of the values from expected set are part of actual e.g.
480
484
481
-
*Example 2.*
485
+
```sql
486
+
create or replace package ut_duplicate_test is
487
+
488
+
--%suite(Sample Test Suite)
489
+
490
+
--%test(Ref Cursor contain duplicates)
491
+
procedure ut_duplicate_include;
492
+
493
+
end ut_duplicate_test;
494
+
/
495
+
496
+
create or replace package body ut_duplicate_test is
497
+
procedure ut_duplicate_include is
498
+
l_actual sys_refcursor;
499
+
l_expected sys_refcursor;
500
+
begin
501
+
open l_expected for select mod(level,2) as rn from dual connect by level <5;
502
+
open l_actual for select mod(level,8) as rn from dual connect by level <9;
503
+
ut.expect(l_actual).to_include(l_expected);
504
+
end;
505
+
506
+
end ut_duplicate_test;
507
+
```
508
+
509
+
Will result in failure test message
510
+
511
+
```sql
512
+
1) ut_duplicate_include
513
+
Actual: refcursor [ count =8 ] was expected to include: refcursor [ count =4 ]
514
+
Diff:
515
+
Rows: [ 2 differences ]
516
+
Missing: <RN>0</RN>
517
+
Missing: <RN>1</RN>
518
+
```
519
+
520
+
521
+
522
+
The negated version of `include / contain` ( `not_to_include`/ `not_to_contain` ) is successful only when all values from expected set are not part of actual (they are disjoint and there is no overlap).
@@ -488,7 +535,7 @@ Set 1 is defined as [ A , B , C ]
488
535
489
536
490
537
491
-
*Example 2.*
538
+
*Example 4.*
492
539
493
540
Set 1 is defined as [ A , B , C , D ]
494
541
@@ -498,7 +545,7 @@ Set 1 is defined as [ A , B , C , D ]
498
545
499
546
500
547
501
-
*Example 3*
548
+
*Example 5.
502
549
503
550
Set 1 is defined as [ A , B , C ]
504
551
@@ -681,9 +728,9 @@ utPLSQL is capable of comparing compound data-types including:
681
728
### Notes on comparison of compound data
682
729
- Compound data can contain elements of any data-type. This includes blob, clob, object type, nested table, varray or even a nested-cursor within a cursor.
683
730
684
-
-Nested table and varray types are compared as **ordered lists of elements**. If order of elements differ, expectation will fail.
731
+
-Attributes in nested table and array types are compared as **ordered lists of elements**. If order of attributes in nested table and array differ, expectation will fail.
685
732
686
-
-Cursors are compared as **unordered list of elements** by default. If order of elements is of importance the option has to be passed to enforce column order comparison `ordered_columns` e.g.
733
+
-Columns in cursors are compared as **unordered list of elements** by default. If order of columns in cursor is of importance the option has to be passed to enforce column order comparison `ordered_columns` e.g.
0 commit comments