Testing your report
The report you have just created is a reusable part and requires information from your BusinessExpenseView part to run properly:
•The host variable containing the employee name
•Business expense information
If you want to test the report from its own Composition Editor, you will need to provide test data. A convenient way of doing this is to override the instance method finalInitialize and set values for the host variable and the ordered collection at that point.
1. Switch to the Script Editor for BusinessExpenseReport and display private instance methods.
2. Create a new method called finalInitialize and code it as follows. This method sets the host variable to 'Graham' and creates three expense entries in the ordered collection.
Note:
You can copy this block of code from the online version of this book and paste it into the Script Editor.
finalInitialize
"Provide information to the report for testing"
((self subpartNamed: 'Multiple Row Query1') valueOfAttributeNamed: 'name'
selector: #'IS_name') == nil
ifTrue: [(self subpartNamed: 'Multiple Row Query1')
valueOfAttributeNamed: 'name'
selector: #'IS_name'
ifAbsent: ]
put: 'Graham'].
(self subpartNamed: 'Expenses') value:
(Array with: (BusinessExpense new
date: (Date today);
reason: 'Sales call';
airfare: 200;
room: 100;
meals: 50;
misc: 10;
yourself)
with: (BusinessExpense new
date: ((Date today) addDays: 1);
reason: 'Sales call';
airfare: 0;
room: 100;
meals: 75;
misc: 0;
yourself)
with: (BusinessExpense new
date: ((Date today) addDays: 2);
reason: 'Sales call';
airfare: 0;
room: 100;
meals: 65;
misc: 5;
yourself)).
3. Save this change and select
, the
Test button, to test your report.
It should look similar to the following:
Your report will run in a report viewer that is embedded in a report tester window. From the Report menu in this window, you can select Preview to display a printer-formatted preview of the report or Print to print the report.
Last modified date: 08/17/2018