swtbot 测试中如何解决no tests found

    SWTBot是一个用于测试eclipse plugin及基于swt的应用程序的框架。该项目目前已经放到org.eclipse组织下了。对于GUI测试,SWTBot相当好用。其灵活的API,让开发人员使用起来得心应手。下面是最近在开发中遇到的问题,总结出来,供大家参考。

     在写SWTBot测试程序时,定义一个test,我原先是继承Junit的TestCase类,使用Junit3来运行测试,其工作正常。后来发现SWTBot有一个类SWTBotEclipseTestCase,其定义了一些针对widget的断言方法。这些方法相当有用。因此把自己的测试类改为继承此类,但是再用Junit3来运行时,就提示junit.framework.AssertionFailedError: No tests found in XXX.class。 一开始百思不得其解,后来通过网上搜索,发现原来SWTBotEclipseTestCase是基于Junit4来写的。其测试风格与Juint3不兼容。因此使用Junit4来运行该测试就可以了。

下面是引用的内容:
Hi Marko,

Thanks for this input. I think I understand what the problem has been all along.

I'd like to clarify that SWTBot does work with junit3 style tests, but you need to depend on the junit4 plugin in order to do this.

The reason for this is the fact that the SWTBot launcher is compiled against JUnit 4.x and gets confused when it sees your tests are running against junit 3.x.

Could you please verify this behavior ? I'll update the user guide and documentation about this particular case, the documentation is quite out of date, and has not been updated in a while after the move to junit4.

-- Ketan

http://www.eclipse.org/newsportal/article.php?id=428&group=eclipse.swtbot#428

你可能感兴趣的:(eclipse,框架,工作,PHP,JUnit)