Accessing Cycle Settings
Cycle projects have standard project settings (.cycproj file) and user settings (.cycuser) that control how tests are run. These settings have suite-wide scope, meaning that they are accessible to all tests during test execution. They are also immutable during a test run. For simplicity and convenience, Cycle passes all settings to each plugin at the start of a test run. The plugin then stores the settings and injects them into step definitions through the SuiteContext object so that the steps can access any settings they need.
There are three kinds of settings that are passed from Cycle to plugins:
- Standard settings
- Stored connections
- Stored credentials
Standard settings
Standard settings are flat entries in either the project or user settings files. They are simply key/value pairs. Most of the settings in the project and user files are standard settings. They are accessed in step definition call methods through the injected suite context object. The example code below shows how to access various standard settings. The names for the settings come directly from the project and user settings files.
String outputDirectory = suiteContext.getCycleSettings().getSettingAsString("OutputDirectory");
Boolean webScreenshots = suiteContext.getCycleSettings().getSettingAsBoolean("WebScreenshots");
long webdriverDefaultTimer = suiteContext.getCycleSettings().getSettingAsNumber("WebdriverDefaultTimeout").longValue();
Stored connections
Stored connections are connection objects containing name, type, and URL. The project settings store a list of these connections. The example code below shows how to get them:
StoredConnection connection = suiteContext.getCycleSettings().getConnection("myConnectionName");
Stored credentials
Stored credentials are credential objects containing name, username, and password. User settings store a list of these credentials. The example code below shows how to get them:
StoredCredential credential = suiteContext.getCycleSettings().getCredential("myCredentialName");