大家新年好啊 问个问题android junit test不捕获异常
如题 我用junit测试下面这段代码:
String xml="<?xml version='1.0' encoding='utf-8'?><Body><Request OperType='RHXUEXING'>" +
"</Request>" +"</Body>";
HttpTransportSE ht = new HttpTransportSE(Init.SERVICE_URL);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER12);
SoapObject request = new SoapObject(Init.SERVICE_NS, Init.methodName);
request.addProperty("xmlString",xml);
envelope.bodyOut = request;
try
{
ht.call(null, envelope);
if (envelope.getResponse() != null)
{
SoapObject result = (SoapObject) envelope.bodyIn;
String responseString = result.getProperty(0).toString();
System.out.println(responseString);
}
}catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
可是这段代码 没有捕获异常(实际上是不能用的服务器连不上!)
但是还是出现了绿条 怎么回事啊