|
1 | | - |
| 1 | + |
2 | 2 |
|
3 | 3 | # Advanced data comparison |
4 | 4 |
|
@@ -126,6 +126,85 @@ end; |
126 | 126 |
|
127 | 127 | ``` |
128 | 128 |
|
| 129 | +Example of `include / exclude` for anydata.convertCollection |
| 130 | + |
| 131 | +```plsql |
| 132 | +create or replace type person as object( |
| 133 | + name varchar2(100), |
| 134 | + age integer |
| 135 | +) |
| 136 | +/ |
| 137 | +create or replace type people as table of person |
| 138 | +/ |
| 139 | +
|
| 140 | +create or replace package ut_anydata_inc_exc IS |
| 141 | +
|
| 142 | + --%suite(Anydata) |
| 143 | +
|
| 144 | + --%test(Anydata include) |
| 145 | + procedure ut_anydata_test_inc; |
| 146 | +
|
| 147 | + --%test(Anydata exclude) |
| 148 | + procedure ut_anydata_test_exc; |
| 149 | + |
| 150 | + --%test(Fail on age) |
| 151 | + procedure ut_fail_anydata_test; |
| 152 | + |
| 153 | +end ut_anydata_inc_exc; |
| 154 | +/ |
| 155 | +
|
| 156 | +create or replace package body ut_anydata_inc_exc IS |
| 157 | +
|
| 158 | + procedure ut_anydata_test_inc IS |
| 159 | + l_actual people := people(person('Matt',45)); |
| 160 | + l_expected people :=people(person('Matt',47)); |
| 161 | + begin |
| 162 | + ut3.ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)).include('NAME'); |
| 163 | + end; |
| 164 | +
|
| 165 | + procedure ut_anydata_test_exc IS |
| 166 | + l_actual people := people(person('Matt',45)); |
| 167 | + l_expected people :=people(person('Matt',47)); |
| 168 | + begin |
| 169 | + --Arrange |
| 170 | + ut3.ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)).exclude('AGE'); |
| 171 | + end; |
| 172 | +
|
| 173 | + procedure ut_fail_anydata_test IS |
| 174 | + l_actual people := people(person('Matt',45)); |
| 175 | + l_expected people :=people(person('Matt',47)); |
| 176 | + begin |
| 177 | + --Arrange |
| 178 | + ut3.ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)).include('AGE'); |
| 179 | + end; |
| 180 | +
|
| 181 | +end ut_anydata_inc_exc; |
| 182 | +/ |
| 183 | +
|
| 184 | +``` |
| 185 | + |
| 186 | +will result in : |
| 187 | + |
| 188 | +```sql |
| 189 | +Anydata |
| 190 | + Anydata include [.044 sec] |
| 191 | + Anydata exclude [.035 sec] |
| 192 | + Fail on age [.058 sec] (FAILED - 1) |
| 193 | + |
| 194 | +Failures: |
| 195 | + |
| 196 | + 1) ut_fail_anydata_test |
| 197 | + Actual: ut3.people [ count = 1 ] was expected to equal: ut3.people [ count = 1 ] |
| 198 | + Diff: |
| 199 | + Rows: [ 1 differences ] |
| 200 | + Row No. 1 - Actual: <AGE>45</AGE> |
| 201 | + Row No. 1 - Expected: <AGE>47</AGE> |
| 202 | +``` |
| 203 | + |
| 204 | + |
| 205 | + |
| 206 | +Example of exclude |
| 207 | + |
129 | 208 | Only the columns 'RN', "A_Column" will be compared. Column 'SOME_COL' is excluded. |
130 | 209 |
|
131 | 210 | This option can be useful in scenarios where you need to narrow-down the scope of test so that the test is only focused on very specific data. |
|
0 commit comments