JUnit 测试抛出 NullPointerException
JUnit testing throw NullPointerException
我需要在 JUnit5(基于接口)中测试一个函数。我没有实施。如果函数的参数之一为空,我需要抛出 NullPointerException。我的问题是,如何测试此函数以抛出 NullPointerException?谢谢!
你能把问题解释的更清楚一点吗?什么
without using the function's output (only the parameters)?
是什么意思?
JUnit 具有测试方法是否抛出异常的方法
Exception exception = assertThrows(NumberFormatException.class, () -> {
Integer.parseInt("1a");
});
我需要在 JUnit5(基于接口)中测试一个函数。我没有实施。如果函数的参数之一为空,我需要抛出 NullPointerException。我的问题是,如何测试此函数以抛出 NullPointerException?谢谢!
你能把问题解释的更清楚一点吗?什么
without using the function's output (only the parameters)?
是什么意思?
JUnit 具有测试方法是否抛出异常的方法
Exception exception = assertThrows(NumberFormatException.class, () -> {
Integer.parseInt("1a");
});