我想用SWTBot测试一个简单的SWT GUI应用程序.不幸的是,我不知道如何开始.有几个教程描述了Eclipse插件的测试,但我找不到任何关于我的问题的内容.我甚至不知道是否有可能.
我的RCP是在3.x Eclipse上创建的,现在使用兼容层在4.x上.这是我的设置:我有两个插件:xyz-plugin和xyz-rcp-plugin.我的RCP应用程序由这两个插件组成.我有一个Test片段(xyz-test),其主机插件是xyz-plugin并包含SWTBot测试.我的产品配置指向plugin.xml中定义的应用程序xyz-rcp-plugin.
当我通过Eclipse运行SWTBot测试时,一切正常.我将它指向Main选项卡上的正确应用程序,它会启动正确的应用程序.
当我尝试通过Maven(使用mvn integration-test)运行它时,在启动用于测试的UI的命令之后,没有UI打开,它只是报告说有测试失败但它实际上甚至从未到达测试我的案例的阶段.
我觉得这种情况正在发生,因为我的测试片段只有xyz-plugin其主机,因此知道它的依赖性,但实际上包含应用程序,xyz-rcp-plugin所以我猜它不会将该插件带入测试工作区.实际上,当我省略<application>pom文件中的配置时,测试运行; 它简单地启动默认的Eclipse SDK.
那么,如果带有应用程序的插件不是测试插件的依赖项,我如何让SWTBot测试运行我的应用程序?
下面是我的测试片段的pom文件,
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.xyz</groupId>
<artifactId>all</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>com.xyz.test</artifactId>
<packaging>eclipse-test-plugin</packaging>
<properties>
<ui.test.vmargs></ui.test.vmargs>
</properties>
<profiles>
<profile>
<id>macosx</id>
<activation>
<os>
<family>mac</family>
</os>
</activation>
<properties>
<ui.test.vmargs>-XstartOnFirstThread</ui.test.vmargs>
</properties>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<useUIHarness>true</useUIHarness>
<useUIThread>false</useUIThread>
<product>com.xyz.rcp.product</product>
<application>com.xyz.rcp.Application</application>
<argLine>${ui.test.vmargs}</argLine>
<dependencies>
<dependency>
<!-- explicit dependency is only needed …Run Code Online (Sandbox Code Playgroud) 我正在eclipse 2019-09中在docker内部运行swtbot测试,如果我使用eclipse 2019-09从主机上运行它们,则测试运行正常,但是当我在docker中运行它们时,出现以下错误
!SESSION 2019-11-12 20:17:58.723 ----------------------------------------
-------
eclipse.buildId=unknown
java.version=11.0.5
java.vendor=AdoptOpenJDK
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Framework arguments: -swtbot -suite C:/testrun/NIGHTLY -application
org.eclipse.swtbot.eclipse.junit.headless.swtbottestapplication -product
org.eclipse.platform.ide -testApplication
C:/tmp/eclipse/plugins/org.eclipse.ui.ide.workbench -testPluginName
ui.test -className ui.test.collection.BasicTests
Command-line arguments: -swtbot -suite C:/testrun/NIGHTLY -application
org.eclipse.swtbot.eclipse.junit.headless.swtbottestapplication -product
org.eclipse.platform.ide -testApplication
C:/tmp/eclipse/plugins/org.eclipse.ui.ide.workbench -data
C:/tmp/eclipse/workspace -testPluginName ui.test -className
ui.test.collection.BasicTests -debug -clean
!ENTRY org.eclipse.osgi 4 0 2019-11-12 20:18:27.576
!MESSAGE Application error
!STACK 1
org.eclipse.swt.SWTError: No more handles
at org.eclipse.swt.SWT.error(SWT.java:4737)
at org.eclipse.swt.SWT.error(SWT.java:4626)
at org.eclipse.swt.SWT.error(SWT.java:4597)
at org.eclipse.swt.widgets.Widget.error(Widget.java:452)
at org.eclipse.swt.widgets.TaskBar.createHandle(TaskBar.java:75)
at org.eclipse.swt.widgets.TaskBar.<init>(TaskBar.java:68)
at org.eclipse.swt.widgets.Display.getSystemTaskBar(Display.java:2512) …Run Code Online (Sandbox Code Playgroud) 我们使用SWTBot编写功能测试.测试某些情况非常困难,一些程序员直接从实现中使用类及其方法(例如,类中的调用方法AddUserDialog等).这是好方法吗?为什么?
请下一个qustion.SWTBot足以测试基于Eclipse的RCP应用程序吗?是否有必要编写单元测试?
注意:我们是scrum团队.
我正在使用SWTBot为RCP应用程序运行UI测试,当在Eclipse IDE中启动测试时,该测试工作正常。现在,我想在Maven中运行测试,到目前为止也可以运行。不幸的是,通过依赖关系链org.eclipse.swtbot.eclipse.finder --> org.eclipse.ui.editors --> org.eclipse.ui.ide,org.eclipse.ui.ide它也存在于运行测试的应用程序中。使用此捆绑软件,会出现一些意外的菜单项,并且应该在测试运行时中排除捆绑软件。如何做到这一点?
在eclipse中运行测试时,我只是org.eclipse.ui.ide在SWTBot测试启动配置中排除了捆绑软件,一切都按预期进行了。
在我的SWTBot测试中,我试图打开(并单击)右键单击项目浏览器中的打开项目时出现的菜单(包含New,Refactor,Import等的菜单)
我试着用
`treeItem.contextMenu("Refactor").menu("Rename...").click();
Run Code Online (Sandbox Code Playgroud)
并得到了WidgetNotFoundException.
请帮忙.
swtbot ×6
eclipse ×3
eclipse-rcp ×3
java ×2
testing ×2
tycho ×2
docker ×1
gui-testing ×1
maven ×1
swt ×1
unit-testing ×1