SWTBot中运行中那些参数控制

Can I slow down the execution speed of SWTBot tests?

Yes you can! To slow down the speed of execution of SWTBot, you need to set the system property "org.eclipse.swtbot.playback.delay". This delay is in milliseconds. You can also set this property in code as follows:

// slow down tests
SWTBotPreferences.PLAYBACK_DELAY = 10;
// set to the default speed
SWTBotPreferences.PLAYBACK_DELAY = 0;

Can I change the timeout for execution of SWTBot tests?

Yes you can! To change the timeout, you need to set the system property "org.eclipse.swtbot.search.timeout". The timeout is specified in milliseconds. You can also set this property in code as follows:

// increase timeout to 10 seconds
SWTBotPreferences.TIMEOUT = 10000;
// set to the default timeout of 5 seconds
SWTBotPreferences.TIMEOUT = 5000;

Can I change the poll delay for evaluating conditions in SWTBot tests?

Yes you can! To change the poll delay, you need to set the system property "org.eclipse.swtbot.playback.poll.delay". The poll delay is specified in milliseconds. You can also set this property in code as follows:

// increase timeout to 1 second
SWTBotPreferences.DEFAULT_POLL_DELAY = 1000;
// set to the default timeout of 500ms.
SWTBotPreferences.DEFAULT_POLL_DELAY = 500;

         

在swtbot运行中总存在一些控制参数如超时时间,失败截屏数量等.具体请看下面不解释:

public interface SWTBotPreferenceConstants {

	/** @see SWTBotPreferences#DEFAULT_KEY */
	public static final String	KEY_DEFAULT_KEY					= "org.eclipse.swtbot.search.defaultKey";
	/** @see SWTBotPreferences#TIMEOUT */
	public static final String	KEY_TIMEOUT						= "org.eclipse.swtbot.search.timeout";

	/** @see SWTBotPreferences#PLAYBACK_DELAY */
	public static final String	KEY_PLAYBACK_DELAY				= "org.eclipse.swtbot.playback.delay";
	/** @see SWTBotPreferences#DEFAULT_POLL_DELAY */
	public static final String	KEY_DEFAULT_POLL_DELAY			= "org.eclipse.swtbot.playback.poll.delay";

	/** @see SWTBotPreferences#MAX_ERROR_SCREENSHOT_COUNT */
	public static final String	KEY_MAX_ERROR_SCREENSHOT_COUNT	= "org.eclipse.swtbot.screenshots.error.maxcount";
	/** @see SWTBotPreferences#SCREENSHOTS_DIR */
	public static final String	KEY_SCREENSHOTS_DIR				= "org.eclipse.swtbot.screenshots.dir";
	/** @see SWTBotPreferences#SCREENSHOT_FORMAT */
	public static final String	KEY_SCREENSHOT_FORMAT			= "org.eclipse.swtbot.screenshots.format";

	/** @see SWTBotPreferences#KEYBOARD_LAYOUT */
	public static final String	KEY_KEYBOARD_LAYOUT				= "org.eclipse.swtbot.keyboard.layout";
	/** @see SWTBotPreferences#TYPE_INTERVAL */
	public static final String	KEY_TYPE_INTERVAL				= "org.eclipse.swtbot.keyboard.interval";
	/** @see SWTBotPreferences#KEYBOARD_STRATEGY */
	public static final String	KEY_KEYBOARD_STRATEGY			= "org.eclipse.swtbot.keyboard.strategy";

}
	/**
	 * The default key used to match SWT widgets. Defaults to {@code org.eclipse.swtbot.widget.key}. To set another
	 * default use the system property
	 * {@value org.eclipse.swtbot.swt.finder.utils.SWTBotPreferenceConstants#KEY_DEFAULT_KEY}.
	 */
	public static String		DEFAULT_KEY					= System.getProperty(KEY_DEFAULT_KEY, "org.eclipse.swtbot.widget.key");

	/**
	 * The timeout for finding widgets among other things. Defaults to 5000ms. To set another default use the system
	 * property {@value org.eclipse.swtbot.swt.finder.utils.SWTBotPreferenceConstants#KEY_TIMEOUT}.
	 */
	public static long			TIMEOUT						= toLong(System.getProperty(KEY_TIMEOUT, "5000"), 5000);

	/**
	 * The speed of playback in milliseconds. Defaults to 0. To set another default, use the system property {@code
	 * org.eclipse.swtbot.playback.delay}.
	 */
	public static long			PLAYBACK_DELAY				= toLong(System.getProperty(KEY_PLAYBACK_DELAY, "0"), 0);

	/**
	 * The maximum number of screenshots that SWTBot should capture. Defaults to 100. To set another default use the
	 * system property
	 * {@value org.eclipse.swtbot.swt.finder.utils.SWTBotPreferenceConstants#KEY_MAX_ERROR_SCREENSHOT_COUNT}.
	 */
	public static int			MAX_ERROR_SCREENSHOT_COUNT	= toInt(System.getProperty(KEY_MAX_ERROR_SCREENSHOT_COUNT, "100"), 100);

	/**
	 * The directory in which screenshots should be generated. Defaults to "screenshots". To set another default use the
	 * system property {@value org.eclipse.swtbot.swt.finder.utils.SWTBotPreferenceConstants#KEY_SCREENSHOTS_DIR}.
	 */
	public static String		SCREENSHOTS_DIR				= System.getProperty(KEY_SCREENSHOTS_DIR, "screenshots");

	/**
	 * The screenshot image format to be used. Defaults to "jpeg". To set another default use the system property
	 * {@value org.eclipse.swtbot.swt.finder.utils.SWTBotPreferenceConstants#KEY_SCREENSHOT_FORMAT}. The value must be
	 * one these: BMP, GIF, ICO, JPEG, JPG, PNG or TIFF.
	 */
	public static String		SCREENSHOT_FORMAT			= System.getProperty(KEY_SCREENSHOT_FORMAT, "jpeg");

	/**
	 * The keyboard layout. This value is autodetected at runtime. This can be set using the system property
	 * {@value org.eclipse.swtbot.swt.finder.utils.SWTBotPreferenceConstants#KEY_KEYBOARD_LAYOUT}.
	 * <p>
	 * <strong>Note:</strong> the layout must be of the form foo.bar.baz.[MAC_][LANGUAGE_][COUNTRY_][VARIANT_] This
	 * expects a file named "foo/bar/baz/[MAC_][LANGUAGE_][COUNTRY_][VARIANT_].keyboard"
	 * </p>
	 * Eg:
	 * <table border="1">
	 * <tr>
	 * <th align="left"><b>Layout Name</b></th>
	 * <th align="left"><b>Configuration File</b></th>
	 * </tr>
	 * <tr>
	 * <td>com.foo.bar.MAC.EN.US</td>
	 * <td>com/foo/bar/MAC_EN_US.keyboard</td>
	 * </tr>
	 * <tr>
	 * <td>com.foo.bar.MAC.EN_GB</td>
	 * <td>com/foo/bar/MAC_EN_GB.keyboard</td>
	 * </tr>
	 * <tr>
	 * <td>com.foo.bar.FR_FR</td>
	 * <td>com/foo/bar/FR_FR.keyboard</td>
	 * </tr>
	 * <tr>
	 * <td>com.foo.bar.DE</td>
	 * <td>/com/foo/bar/DE.keyboard</td>
	 * </tr>
	 * </table>
	 *
	 * @see Locale
	 */
	public static String		KEYBOARD_LAYOUT				= System.getProperty(KEY_KEYBOARD_LAYOUT, KeyboardLayoutDetector
																	.detectKeyboard());

	/**
	 * The the time interval in milliseconds between typing characters in a string. Defaults to 50ms. To set another
	 * default use the system property {@code org.eclipse.swtbot.keyboard.interval}.
	 */
	public static int			TYPE_INTERVAL				= toInt(System.getProperty(KEY_TYPE_INTERVAL, "50"), 50);
	/**
	 * The default keyboard strategy. Defaults to org.eclipse.swtbot.swt.finder.keyboard.AWTKeyboardStrategy. To set
	 * another default use the system property {@code org.eclipse.swtbot.keyboard.strategy}. This property must be set
	 * to a subclass of {@link KeyboardStrategy}.
	 *
	 * @see KeyboardStrategy
	 * @see Keyboard
	 */
	public static String		KEYBOARD_STRATEGY			= System.getProperty(KEY_KEYBOARD_STRATEGY,
																	"org.eclipse.swtbot.swt.finder.keyboard.AWTKeyboardStrategy");

	/**
	 * The default time delay between successive polling while waiting for a condition to be evaluated. Defaults to
	 * 500ms. To set another default use the system property
	 * {@value org.eclipse.swtbot.swt.finder.utils.SWTBotPreferenceConstants#KEY_DEFAULT_POLL_DELAY}.
	 *
	 * @see SWTBot#waitUntil(ICondition, long, long)
	 * @see SWTBot#waitWhile(ICondition, long, long)
	 */
	public static final long	DEFAULT_POLL_DELAY			= toLong(System.getProperty(KEY_DEFAULT_POLL_DELAY, "500"), 500);

猜你喜欢

转载自topmanopensource.iteye.com/blog/1971276