SmsMessage.calculateLength() 在 Junit 测试应用程序中返回空引用
我正在为一个计算短信长度的类编写测试用例
class A {
public int getLength() {
int[] size = SmsMessage.calculateLength(" ", false);
return size[1] + size[2];
}
}
测试代码
@Test
public void Should_equal_When_called_calculateLength() {
A obj = new A();
assert(160, obj.getLength());
}
我在“getLength()”方法中获取数组的“大小”空引用,如果我运行我的应用程序它永远不会返回空引用
什么可以是什么原因?
I was writing test cases for a class where an SMS message length is calculated
class A {
public int getLength() {
int[] size = SmsMessage.calculateLength(" ", false);
return size[1] + size[2];
}
}
Test code
@Test
public void Should_equal_When_called_calculateLength() {
A obj = new A();
assert(160, obj.getLength());
}
I'm getting the "size" in "getLength()" method null reference of an array where if I run my app it never returns null reference
What could be the reason?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当我在上面添加以下内容时,我的测试类测试方法通过了 - 没有为空引用抛出异常
When I added the following above my test class test method passed - no exception thrown for null reference