Java 方法如下所示
public String generateResponseXML(List<Error> parsingErrors)
throws XMLStreamException {
Map<String, String> additionalNamespaces = new HashMap<String, String>();
if (successfulResponse){
additionalNamespaces.put(
ServiceInterface.COMMON_NAMESPACE_PREFIX,
ServiceInterface.COMMON_NAMESPACE);
additionalNamespaces.put(
ServiceInterface.COMMON_NAMESPACE_PREFIX,
ServiceInterface.COMMON_NAMESPACE);
}
else {
additionalNamespaces.put(
ServiceInterface.NAMESPACE_PREFIX,
ServiceInterface.NAMESPACE);
additionalNamespaces.put(
ServiceInterface.NAMESPACE_PREFIX,
ServiceInterface.NAMESPACE);
}
当我在 Junit Test 类中编写以下代码时:
String responseXML = xyzPayment.generateResponseXML( Errors );
当successfulResponse 需要为真时,它不包括代码。如何覆盖successfulResponse 为真的代码,而不是只覆盖else 部分。请指导我如何在这里实现代码覆盖率?