Preferences Contexts
Introduction
Preferences contexts ensure that correct Application-Under-Test preferences are configured before test execution. This can be particularly useful when preferences which control the behavior of pop-up dialogs are being set in your AUT. The well-known example, while not completely relevant to test execution, is the Confirm Exit dialog, which has the “Always exit without prompt” checkbox.
The Preferences Context editor displays tree of all available preferences and allows modifying/removing some of their values.
Example
In UML Lab when a user saves an UML diagram for the first time, the dialog popup appears which asks whether to turn automatic code generation on or off.
Based on user input, it modifies its internal property com.yattasolutions.codegen.GenerateCodeOnSave
and also sets com.yattasolutions.umllab.dontshow.generateCodeOnSave
to true
.
Thus, if a test case is recorded for the first time, clicking on any option on the dialog popup is recorded as well, but later this dialog does not appear and, as a result, execution fails since it cannot find the specified dialog. There are two ways to ensure that test always passes in this case:
- Create preferences context with
dontshow.generateCodeOnSave
set tofalse
- Create preferences context with
dontshow.generateCodeOnSave
set totrue
and remove script lines responsible for this dialog in the Test Editor
Interaction with Workspace context
Project-specific preferences are associated with Eclpse workspace projects. Preferences context with such preferences will fail if associated projects are not present in the workspace. Therefore Preferences context may depend on workspace context to set projects up. To prevent this, either:
- manually remove corresponding project preference nodes from Preference context
- or use a paired workspace context.
- Ensure that your preference context runs after the workspace context (i.e. the preference context is placed below the workspace context in the Contexts section of the Test Editor or Group context).