简体   繁体   English

Selenium JUnit测试失败

[英]Selenium JUnit Tests failed

I am learning Selenium with the aim of exporting UI tests into JUnit tests and then running them in a CI build. 我正在学习Selenium,旨在将UI测试导出到JUnit测试中,然后在CI构建中运行它们。

As a basic test I have a Suite.java and a BasicTest.java which is a test case. 作为基本测试,我有一个Suite.java和一个BasicTest.java这是一个测试用例。

I have used the Selenium export and saved the files to the same location. 我已经使用了Selenium导出并将文件保存到相同的位置。

When I try and compile the tests it fails. 当我尝试编译测试时,它失败了。

1st Error - http://pastebin.com/0j37KZ08

To get past this error I add an import to the Suite.java for the BasicTest class, which then gives me the following error: 为了克服此错误,我向BasicTest类的Suite.java添加了一个导入,然后给了我以下错误:

2nd Error - http://pastebin.com/PKxmdj3L

Source code: 源代码:

Suite.java - http://pastebin.com/Q6HVNtqT
BasicTest.java - http://pastebin.com/fKCk6iN2
Ant build.xml - http://pastebin.com/x16zHKP0

Any help appreciated. 任何帮助表示赞赏。

I don't know if you need a Suite here. 我不知道您是否需要套房。 The issue seems to be that you are calling addTestSuite() with your BasicTest.class which does not extend junit.framework.TestCase. 问题似乎是您正在使用BasicTest.class调用addTestSuite(),而不会扩展junit.framework.TestCase。 You should see this if you scrutinize the second error message closely. 如果您仔细检查第二条错误消息,则应该看到此消息。 Of course, you would not subclass junit.framework.TestCase for a JUnit4-style test, so there's a disconnect here as far as what the Suite/framework expects and what you are providing. 当然,对于JUnit4样式的测试,您不会将junit.framework.TestCase子类化,因此,就Suite / framework所期望的以及您所提供的东西而言,这里没有任何联系。 Maybe just avoid using a suite altogether--personally, I haven't bothered much with suites for some time now. 也许只是完全避免使用套件-就个人而言,一段时间以来我对套件并没有太多困扰。 Or, if you are following an example that insists on a suite, you can switch over to the JUnit3-style for purposes of learning. 或者,如果您遵循一个坚持套件的示例,则可以出于学习目的而切换到JUnit3样式。

EDIT: This link should help with JUnit4-style suites if you decide you want to keep the suite. 编辑:如果您决定保留该套件,则此链接应有助于JUnit4样式的套件。

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

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