@@ -567,21 +567,9 @@ create or replace package body test_expectations_cursor is
567567 --Act
568568 ut3.ut.expect(l_actual).to_equal(l_expected);
569569
570- l_expected_message := q'[Actual: (refcursor [ count = 2 ])
571- Data-types:
572- <ROW><RN>NUMBER</RN></ROW>
573- Data:
574- <ROW><RN>1</RN></ROW>%
575- <ROW><RN>6</RN></ROW>%
576- was expected to equal: (refcursor [ count = 3 ])
577- Data-types:
578- <ROW><RN>NUMBER</RN></ROW>
579- Data:
580- <ROW><RN>1</RN></ROW>%
581- <ROW><RN>2</RN></ROW>%
582- <ROW><RN>3</RN></ROW>%
570+ l_expected_message := q'[Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 3 ]
583571Diff:
584- Rows: [ diff count = 2 ]
572+ Rows: [ 2 differences ]
585573 Row No. 2 - Actual: <RN>6</RN>
586574 Row No. 2 - Expected: <RN>2</RN>
587575 Row No. 3 - Missing: <RN>3</RN>]';
@@ -615,7 +603,7 @@ Rows: [ diff count = 2 ]
615603 --Act
616604 ut3.ut.expect(l_actual).to_equal(l_expected);
617605
618- l_expected_message := q'[%
606+ l_expected_message := q'[Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ]
619607Diff:
620608Columns:
621609 Column <RN> data-type is invalid. Expected: NUMBER, actual: VARCHAR2.]';
@@ -636,7 +624,7 @@ Columns:
636624 --Act
637625 ut3.ut.expect(l_actual).to_equal(l_expected);
638626
639- l_expected_message := q'[%
627+ l_expected_message := q'[Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ]
640628Diff:
641629Columns:%
642630 Column <EXPECTED_COLUMN_NAME> [data-type: NUMBER] is missing. Expected column position: 2.%
@@ -659,13 +647,13 @@ Columns:%
659647 --Act
660648 ut3.ut.expect(l_actual).to_equal(l_expected);
661649
662- l_expected_message := q'[%
650+ l_expected_message := q'[Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ]
663651Diff:
664652Columns:
665653 Column <COL_4> is misplaced. Expected position: 2, actual position: 4.
666654 Column <COL_2> is misplaced. Expected position: 3, actual position: 2.
667655 Column <COL_3> is misplaced. Expected position: 4, actual position: 3.
668- Rows:
656+ Rows: [ 2 differences ]
669657 All rows are different as the columns are not matching.]';
670658 l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message;
671659 --Assert
@@ -686,8 +674,9 @@ Rows:
686674 --Act
687675 ut3.ut.expect(l_actual).to_equal(l_expected);
688676
689- l_expected_message := q'[%
690- Rows: [ diff count = 2 ]
677+ l_expected_message := q'[Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ]
678+ Diff:
679+ Rows: [ 2 differences ]
691680 Row No. 1 - Actual: <BAD_COL>-1</BAD_COL>
692681 Row No. 1 - Expected: <BAD_COL>1</BAD_COL>
693682 Row No. 2 - Actual: <BAD_COL>-2</BAD_COL>
@@ -697,6 +686,42 @@ Rows: [ diff count = 2 ]
697686 ut.expect(l_actual_message).to_be_like(l_expected_message);
698687 end;
699688
689+ procedure data_diff_on_20_rows_only is
690+ l_actual sys_refcursor;
691+ l_expected sys_refcursor;
692+ l_actual_message varchar2(32767);
693+ l_expected_message varchar2(32767);
694+ begin
695+ --Arrange
696+ open l_actual for
697+ select rownum
698+ * case when mod(rownum,2) = 0 then -1 else 1 end bad_col
699+ from dual connect by level <=100;
700+ open l_expected for select rownum bad_col from dual connect by level <=110;
701+ --Act
702+ ut3.ut.expect(l_actual).to_equal(l_expected);
703+
704+ l_expected_message := q'[Actual: refcursor [ count = 100 ] was expected to equal: refcursor [ count = 110 ]
705+ Diff:
706+ Rows: [ 60 differences, showing first 20 ]
707+ Row No. 2 - Actual: <BAD_COL>-2</BAD_COL>
708+ Row No. 2 - Expected: <BAD_COL>2</BAD_COL>
709+ Row No. 4 - Actual: <BAD_COL>-4</BAD_COL>
710+ Row No. 4 - Expected: <BAD_COL>4</BAD_COL>
711+ Row No. 6 - Actual: <BAD_COL>-6</BAD_COL>
712+ Row No. 6 - Expected: <BAD_COL>6</BAD_COL>
713+ Row No. 8 - Actual: <BAD_COL>-8</BAD_COL>
714+ Row No. 8 - Expected: <BAD_COL>8</BAD_COL>
715+ %
716+ Row No. 38 - Actual: <BAD_COL>-38</BAD_COL>
717+ Row No. 38 - Expected: <BAD_COL>38</BAD_COL>
718+ Row No. 40 - Actual: <BAD_COL>-40</BAD_COL>
719+ Row No. 40 - Expected: <BAD_COL>40</BAD_COL>]';
720+ l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message;
721+ --Assert
722+ ut.expect(l_actual_message).to_be_like(l_expected_message);
723+ end;
724+
700725 procedure column_and_data_diff is
701726 l_actual sys_refcursor;
702727 l_expected sys_refcursor;
@@ -717,31 +742,15 @@ Rows: [ diff count = 2 ]
717742 select 50 id, 'Mona' first_name, 'Lisa' last_name, date '1550-01-01' as birth_date from dual;
718743 --Act
719744 ut3.ut.expect(l_actual).to_equal(l_expected);
720- l_expected_message := q'[%Actual: (refcursor [ count = 4 ])
721- Data-types:
722- <ROW><ID>NUMBER</ID><LAST_NAME>VARCHAR2</LAST_NAME><FIRST_NAME>VARCHAR2</FIRST_NAME><CREATE_TMSTMP>TIMESTAMP WITH TIME ZONE</CREATE_TMSTMP><CREATED_BY>VARCHAR2</CREATED_BY></ROW>
723- Data:
724- <ROW><ID>10</ID><LAST_NAME>Norris</LAST_NAME><FIRST_NAME>Chuck</FIRST_NAME><CREATE_TMSTMP>%</CREATE_TMSTMP><CREATED_BY>UT3_TESTER</CREATED_BY></ROW>
725- <ROW><ID>20</ID><LAST_NAME>Skywalker</LAST_NAME><FIRST_NAME>Luke</FIRST_NAME><CREATE_TMSTMP>%</CREATE_TMSTMP><CREATED_BY>UT3_TESTER</CREATED_BY></ROW>
726- <ROW><ID>30</ID><LAST_NAME>Bear</LAST_NAME><FIRST_NAME>Teddy</FIRST_NAME><CREATE_TMSTMP>%</CREATE_TMSTMP><CREATED_BY>UT3_TESTER</CREATED_BY></ROW>
727- <ROW><ID>40</ID><LAST_NAME>Lee</LAST_NAME><FIRST_NAME>Bruce</FIRST_NAME><CREATE_TMSTMP>%</CREATE_TMSTMP><CREATED_BY>UT3_TESTER</CREATED_BY></ROW>
728- was expected to equal: (refcursor [ count = 5 ])
729- Data-types:
730- <ROW><ID>NUMBER</ID><FIRST_NAME>VARCHAR2</FIRST_NAME><LAST_NAME>VARCHAR2</LAST_NAME><BIRTH_DATE>DATE</BIRTH_DATE></ROW>
731- Data:
732- <ROW><ID>10</ID><FIRST_NAME>Chuck</FIRST_NAME><LAST_NAME>Norris</LAST_NAME><BIRTH_DATE>%</BIRTH_DATE></ROW>
733- <ROW><ID>20</ID><FIRST_NAME>Luke</FIRST_NAME><LAST_NAME>Skywalker</LAST_NAME><BIRTH_DATE>%</BIRTH_DATE></ROW>
734- <ROW><ID>31</ID><FIRST_NAME>Teddy</FIRST_NAME><LAST_NAME>Bear</LAST_NAME><BIRTH_DATE>%</BIRTH_DATE></ROW>
735- <ROW><ID>40</ID><FIRST_NAME>Brandon</FIRST_NAME><LAST_NAME>Lee</LAST_NAME><BIRTH_DATE>%</BIRTH_DATE></ROW>
736- <ROW><ID>50</ID><FIRST_NAME>Mona</FIRST_NAME><LAST_NAME>Lisa</LAST_NAME><BIRTH_DATE>1550-01-01%</BIRTH_DATE></ROW>
745+ l_expected_message := q'[%Actual: refcursor [ count = 4 ] was expected to equal: refcursor [ count = 5 ]
737746Diff:
738747Columns:
739748 Column <FIRST_NAME> is misplaced. Expected position: 2, actual position: 3.
740749 Column <LAST_NAME> is misplaced. Expected position: 3, actual position: 2.
741750 Column <BIRTH_DATE> [data-type: DATE] is missing. Expected column position: 4.
742751 Column <CREATE_TMSTMP> [position: 4, data-type: TIMESTAMP WITH TIME ZONE] is not expected in results.
743752 Column <CREATED_BY> [position: 5, data-type: VARCHAR2] is not expected in results.
744- Rows: [ diff count = 5 ]
753+ Rows: [ 5 differences ]
745754 Row No. 3 - Actual: <ID>30</ID>
746755 Row No. 3 - Expected: <ID>31</ID>
747756 Row No. 4 - Actual: <FIRST_NAME>Bruce</FIRST_NAME>
0 commit comments