Skip to end of metadata
Go to start of metadata

Preferences contexts allow to ensure that correct Application-Under-Test preferences are applied 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. 


Since preference keys are often not readable by the user, currently there is no way to add some of them manually in the Context editor. Instead, preferences can be imported from a file or captured from Application-Under-Test using the Snapshot  button in the upper-right corner of the Context editor.

Preference context example

In the UML Lab product when a user saves the 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 to false
  • Create preferences context with dontshow.generateCodeOnSave set to true and remove script lines responsible for this dialog in the [Test Editor|Test Editor]
Important

While it is currently not tracked by Q7, the Preferences context may depend on AUT workspace content since the context may contain project-specific preferences. Therefore, it may also depend on a workspace context, if there is one assigned to the test case. In some cases, applying the Preference context fails if referred projects do not exist in the workspace. In order to prevent this, you should either manually remove corresponding project preference nodes or use this context coupled with the workspace context. In latter case, please 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).

Labels: