Addendum #02 – Including all extended pages in permissions testing

As promised in my first addendum post Addendum #01 – Scenario 0032 ‘Test that lookup value shows on standard Customer – List report’ I would pick up one-by-one the out-scoped issues logged on the GitHub repo accompanying the book. This one took a bit longer because of my needed Xmas break and the fact that this one would need some to time get it done.

What was missing?

In chapter 8, test example 9, I discuss how to test permissions. In the context of the LookupValue case these tests can be divided into two groups:

  • Accessing the data, that is reading, inserting, modifying and deleting the data in the tables of our extension, being actually only one table: Lookup Value table. I call this direct data access.
  • Accessing the controls that relate to the data, being the Lookup Value Code field control on the various page extensions. I call this indirect data access.

The direct data access – first group – is addressed fully in the book. The indirect data access – second group -, however, only partly. This was due to the fact that this concerns altogether 36 pages and was too much work with too little importance to get it done at that time. I did define and implement the four following scenarios – for two pages – as examples to the rest:

[SCENARIO #0051] Check lookup value on customer card without permissions

[SCENARIO #0052] Check lookup value on customer card with permission

[SCENARIO #0053] Check lookup value on customer list without permissions

[SCENARIO #0054] Check lookup value on customer list with permissions

The permission tests for the other 34 pages were out-scoped and parked here.

How was it fixed?

Finally, yesterday, I sat down to get the remaining permission tests done. 34 pages, 2 tests each, making up 68 tests! Wow, how to get this completed in as little as possible time?

Well, by extending the ATDD sheet with the 68 additional tests scenarios and making use of the ATDD.TestScriptor PowerShell module that I discuss in chapter 9.

I decided to number these scenarios starting from 0300 as it would not fit in between the numbers used so far, Note that I often do use higher numbers for scenarios that are added later to make clear that the collection of scenarios is never complete. Scenarios keep on added later due to better understanding, reported omissions, etc.

Creating those 68 scenarios is a matter of copy-pasting the four example scenarios listed above and making use of some Excel functions to easily apply the relevant page names. This all leads automatically to relevant texts in the ATDD.TestScriptor Format columns input to the ATDD.TestScriptor module.

The test codeunit generated – this is the final result: LookupValuePermissions2.Codeunit.al – I completed by adopting some code from it’s older sister and doing an additional round of copy-pasting. Yep, there is not a lot of reusability in this final result due to the fact that each page needs to be addressed by a unique TestPage variable.

In about 3 hours I added 68 tests – not a bad performance with less than 3 minutes per test – which are, due to my repo and pipelines setup, automatically executed in any next pipeline run.

These are the two tests for the Blanket Sales Order page:

procedure CheckLookupValueOnBlanketSalesOrderWithoutPermissions()
var
    BlanketSalesOrder: TestPage "Blanket Sales Order";
begin
    //[SCENARIO #0300] Check lookup value on Blanket Sales Order without permissions

    //[GIVEN] Full base starting permissions
    SetFullBaseStartingPermissions();

    //[WHEN] Open Blanket Sales Order 
    BlanketSalesOrder.OpenView();

    //[THEN] Lookup value field not shown
    VerifyLookupValueNotShownOnBlanketSalesOrder(BlanketSalesOrder);
end;

[Test]
procedure CheckLookupValueOnBlanketSalesOrderWithPermissions()
var
    BlanketSalesOrder: TestPage "Blanket Sales Order";
begin
    //[SCENARIO #0301] Check lookup value on Blanket Sales Order with permissions

    //[GIVEN] Full base starting permissions extended with Lookup Value permissions
    SetFullBaseStartingPermissionsExtendedWithLookupValue();

    //[WHEN] Open Blanket Sales Order 
    BlanketSalesOrder.OpenView();

    //[THEN] Lookup value field shown
    VerifyLookupValueShownOnBlanketSalesOrder(BlanketSalesOrder);
end;

Note

As both permissions test codeunits use identical helper functions there is clearly a need for refactoring. I decided, however, not to do this as it would introduce too many changes to the existing code and make repo too much different from what was released with the book.

2 Comments

  1. Pingback: Errata and Updates to my book and GitHub project (2nd edition) – Van Vugt's DynamiXs

  2. Pingback: Addendum #05 – Include Lookup Value in Restore Archived Sales Document feature – Van Vugt's DynamiXs

Leave a Reply

Your email address will not be published. Required fields are marked *