currentCapacity = queue.getCapacityLeft();
if(currentCapacity == queue.getCapacityLeft()) System.out.println("yes");
assertTrue( "Should have resized array",currentCapacity < queue.getCapacityLeft() );
这两个有2个不同的显示:第一个显示“yes”,这意味着当前容量等于queue.getCapacityLeft,但第二个也显示。
这是我的方法:
public int getCapacityLeft() { return 0; }
为什么我会遇到这个问题?
最佳答案
javadoc中指定的assertTrue方法表示该方法:
Asserts that a condition is true. If it isn't it throws an AssertionError with the given message.
因为条件currentCapacity < queue.getCapacityLeft()
为 false 会抛出 AssertionError
并打印消息“应该调整数组大小”,这就是您看到此消息也显示的原因。
关于Java junit.framework.AssertionFailedError 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49268587/