简体   繁体   English

在Maven项目中使用SWTBot

[英]Using SWTBot on a Maven Project

I am relatively new to SWTBot. 我对SWTBot比较陌生。

I have installed it through the "install new software" in eclipse. 我已经通过eclipse中的“安装新软件”安装了它。

I am trying to use it on an SWT application that was imported from an existing maven pom.xml . 我试图在从现有maven pom.xml导入的SWT应用程序上使用它。 This application is not an eclipse plugin. 这个应用程序不是eclipse插件。 Its just a standalone plain SWT application. 它只是一个独立的普通SWT应用程序。

The problem is that I can't seem to be able to import any of SWTBot's classes in a test case. 问题是我似乎无法在测试用例中导入任何SWTBot类。

I am wondering if there is a maven artefact I may need to add? 我想知道是否有一个我可能需要添加的maven artefact? I am not finding one. 我找不到一个。

If there is a more complex setup, how can I set it up? 如果设置更复杂,我该如何设置?

if you installed the swtbot plugin/bundle via eclipse then you'll need an eclipse plugin project that depends on that bundle to hold your tests. 如果您通过eclipse安装了swtbot插件/ bundle,那么您将需要一个依赖于该bundle来进行测试的eclipse插件项目。 Create a new plugin project and edit the manifest file to import the swtbot bundle. 创建一个新的插件项目并编辑清单文件以导入swtbot包。

You will then need a run configuration that will launch the application under test. 然后,您将需要一个运行配置来启动正在测试的应用程序。 I'm not sure how this can be achieved with a standalone maven project, but there's probably a way. 我不确定如何通过独立的maven项目实现这一目标,但可能有一种方法。 If the project under test was an Eclipse application, you'd only need to right-click on your swtbot test and select run as swtbot test. 如果被测项目是Eclipse应用程序,则只需右键单击swtbot测试并选择run as swtbot test。 I don't have an Eclipse with swtbot up and running atm so I can't give more detail, sry 我没有带有swtbot和运行atm的Eclipse,因此我无法提供更多细节,sry

[ EDIT ] [ 编辑 ]

IMHO you should first try to test a dummy eclipse application. 恕我直言,你应该首先尝试测试一个虚拟的Eclipse应用程序。 Put the plugin containing your test and the one containing your dummy app in your workspace, then run the test as described above. 将包含测试的插件和包含虚拟应用程序的插件放在工作区中,然后按上述方法运行测试。 Once you have that running you should have a look at this post and the answer by the maintainer of SWTBot. 一旦你有了这个运行,你应该看看这篇文章和SWTBot维护者的答案。 A new instance of Eclipse will be launched with all UI contributions added by your dummy Eclipse application and the test will be run. 将启动Eclipse的新实例,并由您的虚拟Eclipse应用程序添加所有UI贡献,并将运行测试。

And have you already seen this similar post on SO? 你有没有在SO上看过这个类似的帖子 Sounds promising to me... 听起来很有意义......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM