我对<代码>hashCode和<代码>等进行了一般性测试。 日元星号实验@ Theory
说明。 测试案例类别本身基于。 页: 1
However, when I was trying to test the java.net.InetAddress
class, I have come across a peculiar problem if the method that supplies the data points contains code that throws an exception (in this case an UnknownHostException
):
So I tried two alternatives that both led to the same unsatisfactory result:
2. 宣布该方法为放弃适当的例外:
@DataPoints public static InetAddress[] declareException() throws UnknownHostException { return new InetAddress[] { InetAddress.getByName("not a valid internet address") }; }
a. 明显追捕例外和重新排入为
AssertionError
:@DataPoints public static InetAddress[] rethrowAsAssertionError() { try { return new InetAddress[] { InetAddress.getByName("not a valid internet address") }; } catch(UnknownHostException ex) { throw new AssertionError(ex); } }
在上述两种情况下,均以无助的电文投掷了<>AsertionError。 暴力假设:[],首先与没有<编码>@DataPoints附加说明的方法相同。
是否有任何人知道有办法向日本特尼特(最终是用户)宣传该例外,或者这是否是日本特尼特的丑恶?