As I explain in my book with test example 8 in chapter 8, the testability framework – or actually the test toolkit – does not provide for layout testing, only dataset testing.
Those who bought both the 1st and 2nd edition of my book might have noticed that the verification part of this report test example changed.
1st Edition
The verification code part of the 1st edition was like the following:
local procedure VerifyCustomerWithLookupValueOnCustomerListReport(
No: Code[20]; LookupValueCode: Code[10])
var
Row: array[2] of Integer;
begin
Row[1] := LibraryReportDataset.FindRow(
'Customer_No_', No);
Row[2] := LibraryReportDataset.FindRow(
'Customer_Lookup_Value_Code', LookupValueCode);
Assert.AreEqual(
13, Row[2] - Row[1],
'Delta between columns Customer_No_ and Customer_Lookup_Value_Code')
end;
Where the FindRow(ElementName: Text, ElementValue: Variant)
method, from Library - Report Dataset
(131007), returns the row number for the combination of ElementName
and ElementValue
. In our case the combination of column Customer_No_
or column Customer_Lookup_Value_Code
and its respective value No
or LookupValueCode
. Apparently the row number of column Customer_No_
yielded another value than that of column Customer_Lookup_Value_Code
as you can see from the AreEqual
check where the delta between the row numbers is expected to be 13. This indeed was true on BC14, the version the 1st edition was based on, although you might have expected that the row number should be exactly the same as No
and LookupValueCode
belong to the same customer record.
2nd Edition
When using this code on B19, the version the 2nd edition was based on, the verification did not work as FindRow
returned always 0, as I reported to MS. So, it seemed I could not use FindRow
method anymore and decided to make use of the AssertElementWithValueExists
method from Library - Report Dataset
(131007) as per the following code:
local procedure VerifyCustomerWithLookupValueOnCustomerListReport(
No: Code[20]; LookupValueCode: Code[10])
begin
LibraryReportDataset.AssertElementWithValueExists(
'Customer_No_', No);
LibraryReportDataset.AssertElementWithValueExists(
'Customer_Lookup_Value_Code', LookupValueCode);
end;
I was not very happy, but didn’t have much time to ponder over this. Later, however, a number of attendees to my online course rightfully pointed out that this new verification code was not 100% robust. Why? Well, the checks on the columns Customer_No_
and Customer_Lookup_Value_Code
could both be passing even though these two columns reside in the dataset at unrelated rows. I had to get back and study the issue once more which I did this week. I also added an issue for it to the GitHub of my book: Issue 31 FindRow in “Library – Report Dataset” (131007) yields a different result on BC14 than on BC18.
I tested both solutions on their related version, i.e. BC14 and BC19, again and saw both passing. While debugging the 2nd edition version I, however, noted that FindRow
did not return a 0. It actually returned the same raw number for a related set of columns Customer_No_
and Customer_Lookup_Value_Code
resulting in a delta of 0. This meant that I could revert the 2nd edition version of VerifyCustomerWithLookupValueOnCustomerListReport
to the 1st edition version only changing the expected delta from 13 to 0 as per the below:
local procedure VerifyCustomerWithLookupValueOnCustomerListReport(
No: Code[20]; LookupValueCode: Code[10])
var
Row: array[2] of Integer;
begin
Row[1] := LibraryReportDataset.FindRow(
'Customer_No_', No);
Row[2] := LibraryReportDataset.FindRow(
'Customer_Lookup_Value_Code', LookupValueCode);
Assert.AreEqual(
0, Row[2] - Row[1],
'Delta between row for columns Customer_No_ and Customer_Lookup_Value_Code')
end;
I have updated all version related branches on the GitHub repo. you might notice that I left the two original lines of code as comments.
Case closed.
Pingback: Errata and Updates to my book and GitHub project (2nd edition) – Van Vugt's DynamiXs