我正在使用TestNG和Java运行自动化测试。
这是我的代码的一部分:
private void testConnection(String URL1) throws IOException {
try {
URL url = new URL(URL1);
HttpURLConnection urlConn = (HttpURLConnection) url.openConnection();
urlConn.connect();
assertEquals(HttpURLConnection.HTTP_OK, urlConn.getResponseCode());
} catch (IOException e) {
ConsoleLogger.error("*******************************");
ConsoleLogger.error("Could NOT connect to the server");
ConsoleLogger.error("Entire test is aborted!!!");
ConsoleLogger.error("Please check port and IP again!");
ConsoleLogger.error("*******************************");
throw e;
}
}
Run Code Online (Sandbox Code Playgroud)
现在,我的测试失败了,因为我从URL中获取了一个异常。我可以在控制台中看到错误消息。在带有注释@BeforeSuite的方法中调用此方法。
为什么我不能调试此方法(不是try块也不是catch块)?