在 eclipse 中设置测试输入
我有一些需要在 java 类上执行的方法。
例如,我的方法接收一个类文件作为参数,如下所示:
Information info = grabInformation("class_to_execute");
此方法将运行“class_to_execute”并捕获其输出。我想稍后用给定的期望值断言其输出。
我的问题是:如何设置 eclipse 以便我的测试用例能够找到它将执行的类?将类添加到构建路径就足够了吗?我可以设置一些变量吗?
我不认为 CLASSPATH 与它有任何关系。
I have some methods that would require to execute over a java class.
For example my method receives as argument a class file, something like:
Information info = grabInformation("class_to_execute");
This method would run the "class_to_execute"
and capture its output. And I would like to later assert its output with a given expected value.
My question is: how could I set up eclipse so that my test cases would find the classes that it will execute? Is adding the classes to the build path enough? Are there some variables I could set?
I don't think the CLASSPATH
has anything to do with it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果“class_to_execute”位于另一个项目或 JAR 中,则将其添加到库下的构建路径中。您有理由相信这还不够吗?对于大多数用途,构建路径 == CLASSPATH。
如果您遇到构建路径或 CLASSPATH 问题,如果执行以下操作,调试可能会更容易:
如果找不到该类,则将光标放在错误上并键入 Control+1。 Eclipse 也许能够帮助您自动修复构建路径。
If "class_to_execute" is in another project or JAR, then add it to your Build Path under Libraries. Do you have any reason to believe that's not enough? Build path == CLASSPATH for most purposes.
If you're having Build Path or CLASSPATH problems, it might be easier to debug if you do this:
If it can't find the class, then put your cursor on the error and type Control+1. Eclipse might be able to help you fix the Build Path automatically.