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/expectations.md
+53-49Lines changed: 53 additions & 49 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -145,7 +145,7 @@ utPLSQL provides the following matchers to perform checks on the expected and ac
145
145
-`be_null`
146
146
-`be_true`
147
147
-`equal`
148
-
-`include ` / `contain`
148
+
-`contain`
149
149
-`have_count`
150
150
-`match`
151
151
@@ -433,17 +433,17 @@ end;
433
433
The `a_nulls_are_equal` parameter controls the behavior of a `null = null` comparison.
434
434
To change the behavior of `NULL = NULL` comparison pass the `a_nulls_are_equal => false` to the `equal` matcher.
435
435
436
-
## include / contain
436
+
## contain
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
-
when comparing data using `include / contain` matcher, the data-types of columns for compared cursors must be exactly the same.
440
+
When comparing data using `contain` matcher, the data-types of columns for compared cursors must be exactly the same.
441
441
442
-
The matcher supports all advanced comparison options as `equal`e.g. include , exclude, join_by.
442
+
The matcher supports all advanced comparison options as `equal`like: `include` , `exclude`, `join_by` etc..
443
443
444
-
The matcher is successful when all of the values from expected results are included in actual data set.
444
+
The matcher is successful when actual data set contains all of the values from expected results.
445
445
446
-
The matcher will cause a test to fail if any of expected values are not included in actual data set.
446
+
The matcher will cause a test to fail if actual data set does not contain any of expected values.
447
447
448
448

449
449
@@ -460,23 +460,23 @@ The matcher will cause a test to fail if any of expected values are not included
460
460
union allselect rownum as rn from dual a connect by level <4;
461
461
462
462
--Act
463
-
ut.expect(l_actual).to_include(l_expected);
463
+
ut.expect(l_actual).to_contain(l_expected);
464
464
end;
465
465
```
466
466
467
467
Will result in failure message
468
468
469
469
```sql
470
470
1) ut_refcursors
471
-
Actual: refcursor [ count =9 ] was expected to include: refcursor [ count =6 ]
471
+
Actual: refcursor [ count =9 ] was expected to contain: refcursor [ count =6 ]
472
472
Diff:
473
473
Rows: [ 3 differences ]
474
474
Missing: <ROW><RN>3</RN></ROW>
475
475
Missing: <ROW><RN>2</RN></ROW>
476
476
Missing: <ROW><RN>1</RN></ROW>
477
477
```
478
478
479
-
When duplicate rows are present in expected data set, actual data set must also include the same amount of duplicate.
479
+
When duplicate rows are present in expected data set, actual data set must also include the same amount of duplicates.
480
480
481
481
*Example 2.*
482
482
@@ -488,19 +488,19 @@ create or replace package ut_duplicate_test is
488
488
--%suite(Sample Test Suite)
489
489
490
490
--%test(Ref Cursor contain duplicates)
491
-
procedure ut_duplicate_include;
491
+
procedure ut_duplicate_contain;
492
492
493
493
end ut_duplicate_test;
494
494
/
495
495
496
496
create or replace package body ut_duplicate_test is
497
-
procedure ut_duplicate_include is
497
+
procedure ut_duplicate_contain is
498
498
l_actual sys_refcursor;
499
499
l_expected sys_refcursor;
500
500
begin
501
501
open l_expected for select mod(level,2) as rn from dual connect by level <5;
502
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);
503
+
ut.expect(l_actual).to_contain(l_expected);
504
504
end;
505
505
506
506
end ut_duplicate_test;
@@ -509,8 +509,8 @@ end ut_duplicate_test;
509
509
Will result in failure test message
510
510
511
511
```sql
512
-
1) ut_duplicate_include
513
-
Actual: refcursor [ count =8 ] was expected to include: refcursor [ count =4 ]
512
+
1) ut_duplicate_contain
513
+
Actual: refcursor [ count =8 ] was expected to contain: refcursor [ count =4 ]
514
514
Diff:
515
515
Rows: [ 2 differences ]
516
516
Missing: <RN>0</RN>
@@ -519,7 +519,7 @@ Will result in failure test message
519
519
520
520
521
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).
522
+
The negated version of `contain` ( `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).
523
523
524
524
525
525
@@ -531,7 +531,7 @@ Set 1 is defined as [ A , B , C ]
531
531
532
532
*Set 2 is defined as [A , D , E ]*
533
533
534
-
*Result : This will fail both of options to`to_include` and `not_to_include`*
534
+
*Result : This will fail both of options to`to_contain` and `not_to_contain`*
535
535
536
536
537
537
@@ -541,7 +541,7 @@ Set 1 is defined as [ A , B , C , D ]
541
541
542
542
*Set 2 is defined as [A , B , D ]*
543
543
544
-
*Result : This will be success on option `to_include` and fail `not_to_include`*
544
+
*Result : This will be success on option `to_contain` and fail `not_to_contain`*
545
545
546
546
547
547
@@ -551,33 +551,33 @@ Set 1 is defined as [ A , B , C ]
551
551
552
552
*Set 2 is defined as [D, E , F ]*
553
553
554
-
*Result : This will be success on options `not_to_include` and fail `to_include`*
554
+
*Result : This will be success on options `not_to_contain` and fail `to_contain`*
555
555
556
556
557
557
558
558
Example usage
559
559
560
560
```sql
561
-
create or replace package example_include is
562
-
--%suite(Include test)
561
+
create or replace package example_contain is
562
+
--%suite(Contain test)
563
563
564
-
--%test( Cursor include data from another cursor)
565
-
procedure cursor_to_include;
564
+
--%test( Cursor contains data from another cursor)
565
+
procedure cursor_to_contain;
566
566
567
-
--%test( Cursor include data from another cursor)
568
-
procedure cursor_not_to_include;
567
+
--%test( Cursor contains data from another cursor)
568
+
procedure cursor_not_to_contain;
569
569
570
-
--%test( Cursor fail include)
571
-
procedure cursor_fail_include;
570
+
--%test( Cursor fail on to_contain)
571
+
procedure cursor_fail_contain;
572
572
573
-
--%test( Cursor fail not include)
574
-
procedure cursor_fail_not_include;
573
+
--%test( Cursor fail not_to_contain)
574
+
procedure cursor_fail_not_contain;
575
575
end;
576
576
/
577
577
578
-
create or replace package body example_include is
578
+
create or replace package body example_contain is
579
579
580
-
procedure cursor_to_include is
580
+
procedure cursor_to_contain is
581
581
l_actual SYS_REFCURSOR;
582
582
l_expected SYS_REFCURSOR;
583
583
begin
@@ -594,10 +594,10 @@ create or replace package body example_include is
594
594
select'c'as name from dual;
595
595
596
596
--Act
597
-
ut.expect(l_actual).to_include(l_expected);
597
+
ut.expect(l_actual).to_contain(l_expected);
598
598
end;
599
599
600
-
procedure cursor_not_to_include is
600
+
procedure cursor_not_to_contain is
601
601
l_actual SYS_REFCURSOR;
602
602
l_expected SYS_REFCURSOR;
603
603
begin
@@ -613,10 +613,10 @@ create or replace package body example_include is
613
613
select'f'as name from dual;
614
614
615
615
--Act
616
-
ut.expect(l_actual).not_to_include(l_expected);
616
+
ut.expect(l_actual).not_to_contain(l_expected);
617
617
end;
618
618
619
-
procedure cursor_fail_include is
619
+
procedure cursor_fail_contain is
620
620
l_actual SYS_REFCURSOR;
621
621
l_expected SYS_REFCURSOR;
622
622
begin
@@ -632,10 +632,10 @@ create or replace package body example_include is
632
632
select'e'as name from dual;
633
633
634
634
--Act
635
-
ut.expect(l_actual).to_include(l_expected);
635
+
ut.expect(l_actual).to_contain(l_expected);
636
636
end;
637
637
638
-
procedure cursor_fail_not_include is
638
+
procedure cursor_fail_not_contain is
639
639
l_actual SYS_REFCURSOR;
640
640
l_expected SYS_REFCURSOR;
641
641
begin
@@ -651,7 +651,7 @@ create or replace package body example_include is
651
651
select'e'as name from dual;
652
652
653
653
--Act
654
-
ut.expect(l_actual).not_to_include(l_expected);
654
+
ut.expect(l_actual).not_to_contain(l_expected);
655
655
end;
656
656
end;
657
657
/
@@ -660,26 +660,30 @@ end;
660
660
661
661
662
662
Above execution will provide results as follow:
663
+
Cursor contains data from another cursor
664
+
Cursor contains data from another cursor
665
+
Cursor fail on to_contain
666
+
Cursor fail not_to_contain
663
667
664
668
```sql
665
-
Include test
666
-
Cursor include data from another cursor [.045 sec]
667
-
Cursor include data from another cursor [.039 sec]
668
-
Cursor fail include [.046 sec] (FAILED -1)
669
-
Cursor fail not include [.043 sec] (FAILED -2)
669
+
Contain test
670
+
Cursor contains data from another cursor [.045 sec]
671
+
Cursor contains data from another cursor [.039 sec]
672
+
Cursor fail on to_contain [.046 sec] (FAILED -1)
673
+
Cursor fail not_to_contain [.043 sec] (FAILED -2)
670
674
671
675
Failures:
672
676
673
-
1) cursor_fail_include
674
-
Actual: refcursor [ count =3 ] was expected to include: refcursor [ count =3 ]
677
+
1) cursor_fail_contain
678
+
Actual: refcursor [ count =3 ] was expected to contain: refcursor [ count =3 ]
675
679
Diff:
676
680
Rows: [ 2 differences ]
677
681
Missing: <ROW><NAME>d</NAME></ROW>
678
682
Missing: <ROW><NAME>e</NAME></ROW>
679
-
at "UT3.EXAMPLE_INCLUDE.CURSOR_FAIL_INCLUDE", line71ut.expect(l_actual).to_include(l_expected);
683
+
at "UT3.EXAMPLE_CONTAIN.CURSOR_FAIL_CONTAIN", line71ut.expect(l_actual).to_contain(l_expected);
680
684
681
685
682
-
2) cursor_fail_not_include
686
+
2) cursor_fail_not_contain
683
687
Actual: (refcursor [ count =3 ])
684
688
Data-types:
685
689
<ROW><NAME xml_valid_name="NAME">CHAR</NAME>
@@ -688,15 +692,15 @@ Failures:
688
692
<ROW><NAME>a</NAME></ROW>
689
693
<ROW><NAME>b</NAME></ROW>
690
694
<ROW><NAME>c</NAME></ROW>
691
-
was expected not to include:(refcursor [ count =3 ])
695
+
was expected not to contain:(refcursor [ count =3 ])
692
696
Data-types:
693
697
<ROW><NAME xml_valid_name="NAME">CHAR</NAME>
694
698
</ROW>
695
699
Data:
696
700
<ROW><NAME>a</NAME></ROW>
697
701
<ROW><NAME>d</NAME></ROW>
698
702
<ROW><NAME>e</NAME></ROW>
699
-
at "UT3.EXAMPLE_INCLUDE.CURSOR_FAIL_NOT_INCLUDE", line94ut.expect(l_actual).not_to_include(l_expected);
703
+
at "UT3.EXAMPLE_CONTAIN.CURSOR_FAIL_NOT_CONTAIN", line94ut.expect(l_actual).not_to_contain(l_expected);
700
704
```
701
705
702
706
@@ -1161,7 +1165,7 @@ The matrix below illustrates the data types supported by different matchers.
1161
1165
|**be_less_than**|||| X | X | X | X | X || X | X ||||
1162
1166
|**be_between**|||| X | X | X | X | X | X | X | X ||||
1163
1167
|**equal**| X | X | X | X | X | X | X | X | X | X | X | X | X | X |
0 commit comments