创建套件时如何让 Eclipse 识别 JUnit 测试?
当我使用 Eclipse 创建 JUnit 测试套件时,它没有检测到任何现有测试,并警告“未选择测试类”。
我是从测试类包(test/com/.../package)开始的,选择了包。那里有几个 JUnit 测试,也是通过相同版本的 Eclipse 创建的,但无法选择它们。
我正在使用 JUnit 4。
谢谢!
When I use Eclipse to create a JUnit test suite, it does not detect any existing tests, and warns "No test classes selected."
I started from the test class package (test/com/.../package), and the package is selected. There are several JUnit tests there, also created through the same version of Eclipse, but there is no way to select them.
I am using JUnit 4.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
创建套件的向导当前仅适用于 JUnit 3 测试,请参阅相应的 bugzilla 条目。
The wizard for creating a suite currently only works with JUnit 3 tests, see corresponding bugzilla entry.
对我有用的套件是:
如果您只想运行包中定义的测试子集,这会有所帮助。你们的测试叫什么?尝试重构它们,使它们被称为 Test*.java 或 *Test.java。
A Suite that works for me is :
This helps if you want to run just a subset of tests defined in a package. What are you tests called? Try re-factoring them so they are called either Test*.java or *Test.java.
在 Eclipse 中,您只需右键单击要在其中运行测试的项目/包,然后选择“运行为”> Junit Test - 您可以完全避免以编程方式创建测试套件类。
In Eclipse, you can simply right-click on the project / package you want to run tests in and select
Run as > Junit Test
- you can avoid needing to programmatically create a test suite class completely.