在Eclipse中运行JUnit测试用例时获取java.io.IOException [英] Getting java.io.IOException when running JUnit test case in Eclipse
问题描述
这是我的代码
public class JWebUnitTest extends WebTestCase {
public JWebUnitTest(String name) {
super(name);
}
public void setUp() {
getTestContext().setBaseUrl("http://www.google.com");
}
public void testSearch() {
beginAt("/");
setFormElement("q", "httpunit");
submit("btnG");
clickLinkWithText("HttpUnit");
assertTitleEquals("HttpUnit");
assertLinkPresentWithText("User's Manual");
}
}
在故障跟踪"中,看到以下错误:
In the Failure Trace, I see the following error:
java.lang.RuntimeException:java.io.IOException (下移..) 原因:java.net.SocketException:操作超时:connect:可能是由于无效的地址
java.lang.RuntimeException: java.io.IOException (moving down..) Caused by: java.net.SocketException: Operation timed out: connect: could be due to invalid address
为什么"http://www.google.com/"是无效的地址? 为什么会收到此IOException?
Why is "http://www.google.com/" an invalid address? Why am I getting this IOException?
推荐答案
我建议您尝试使用这些选项中的任何一个
I would suggest you to try any of these options
1.)清理项目一次.项目-清理(在Eclipse中)并重建
1.) Clean the project once . Project - Clean (in Eclipse) and rebuild
2.)尝试将日食更新到最新版本
2.) Try updating your eclipse to latest version
3.)尝试访问您的本地主机服务器(这将显示您的代码或Eclipse是否确实存在问题)
3.) Try to hit your localhost server (This will show whether theres really a problem with ur code or with eclipse)
4.)您应该需要代理.因此,请进行相应的配置
4.) You should be needing a proxy. So configure accordingly
这篇关于在Eclipse中运行JUnit测试用例时获取java.io.IOException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!