我是JUnit的新手,正在尝试为以下方法编写测试用例-
Java类中的方法
componentWillMount() {
for (var i = 0; i < 3; i++) {
this.setValue(this.props.data[i]);
}
}
setValue(rowData) {
let {
checkbox: checkbox,
checked: checked,
data: data,
name: name,
headers: headers
} = this.props;
var json = {};
for (var i = 0; i < headers.length; i++) {
json[headers[i]] = rowData[i];
}
json["checked"] = checked;
this.setState(prevState => { data: [...prevState.data, json] });
{ console.log(this.getValue()) }
}
测试类和方法
@Override
public List<Network> getNetworkList() {
List<Network> networkList = new ArrayList<Network>();
List<Ntwrk> networkListFromDB = getCurrentSession().createCriteria(Ntwrk.class).add(Restrictions.isNotNull("networkName")).list();
//Other Logic
return networkList;
}
我在上面评论中提到的行上收到NullPointerException,却无法弄清问题所在