Writing the test story

Given test example 1, writing the test story isn't a difficult exercise. Have a look at the following code:

procedure AssignBlockedCustomerCategoryToCustomer()
// [FEATURE] Customer Category
var
Customer: Record Customer;
CustomerCategoryCode: Code[20];
begin
// [SCENARIO #0002] Assign blocked customer category to
// customer
// [GIVEN] A blocked customer category
CustomerCategoryCode := CreateBlockedCustomerCategory();
// [GIVEN] A customer
CreateCustomer(Customer);
// [WHEN] Set customer category on customer
asserterror SetCustomerCategoryOnCustomer(
Customer,
CustomerCategoryCode);
// [THEN] Blocked category error thrown
VerifyBlockedCategoryErrorThrown();
end;

First of all, note how asserterror has been applied – in front of the call to the SetCustomerCategoryOnCustomer helper function. This ensures that the platform will expect SetCustomerCategoryOnCustomer to throw an error. asserterror enables the test to continue with the next statement and it will not check the error, as such. So, it is up to us to verify that the expected did occur. If there is no verification of the specific error following asserterror, any error will make your test pass.

Next, note that, based on test example 1, the required variables have already been provided.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.216.205.123