跳到主要內容

發表文章

目前顯示的是 4月, 2013的文章

用SWTBot 在 Eclipse 測試 content assist

SWTbot 是一個 Eclipse plugin 可用來自動測試 Eclipse plugin。 Javadoc 幾點注意 test case運作時必須加上 plug-ins: org.eclipse.core.net org.eclipse.ui.ide.application 執行時可能需要加上JVM參數 -XX:MaxPermSize=512m ,在我的環境下總是會遇到 outofmemoryerror: PermGen Space 模擬按鍵 : http://wiki.eclipse.org/SWTBot/Keyboard_Layouts 以下是簡單的測試案例,其步驟是移動游標到指定位置,並觸發content assist功能,並檢查proposal內容是否如我們預期。 import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor; import org.eclipse.swtbot.eclipse.gef.finder.SWTBotGefTestCase; import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; import org.eclipse.swtbot.swt.finder.utils.Position; import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences; import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; @RunWith(SWTBotJunit4ClassRunner.class) public class Basic extends SWTBotGefTestCase { private static SWTWorkb