java如何Junit测试默认构造函数?
我如何单位这个构造函数
private Item[] items;
private int currentIndex;
/**
* Default Constructor
*/
public Inventory()
{
this.items = new Item[1];
this.currentIndex = 0;
}
你可以在下面搜索框中键入要查询的问题!
我如何单位这个构造函数
private Item[] items;
private int currentIndex;
/**
* Default Constructor
*/
public Inventory()
{
this.items = new Item[1];
this.currentIndex = 0;
}
# 1 楼答案
将非公共测试成员和字段包私有化是标准做法。像这样,
现在只要单元测试与
Inventory
类在同一个包中