public boolean compareRegexString(String testName, String wsValue, String expectValue) {
boolean result = false;
String resultInfo = LR;
resultInfo += "WS: " +wsValue+ LR;
resultInfo += "Expect: " +expectValue+ LR;
/**
* 接下来是判断和记录结果过程
*/
if ((expectValue == null || expectValue.length() == 0) && (wsValue == null || wsValue.length() == 0)) {
result = true;
resultInfo = PASS + LR + resultInfo;
} else {
Pattern pattern = Pattern.compile(expectValue);
Matcher matcher = pattern.matcher(wsValue);
result = matcher.find();
if (result == true) {
resultInfo = PASS + LR + resultInfo;
Assert.assertTrue(result);
} else {
resultInfo = FAIL + LR + resultInfo;
Assert.assertEquals(wsValue, expectValue);
}
}
setStrResultInfo(resultInfo);
writeReportResultInfo(result);
// writeLog(testName);
getReturnMap().put(testName, wsValue);
return result;
}
wsValue= {"code":"10000","msg":null,"data":{"untilnow_pv":0.007830058221967192,"DirectUsage":0.007830058222127264,"Charges_pv":0.007812278694385896,"Feedin_pv":0.0}}
expectValue="untilnow_pv":\S+,"DirectUsage":\S+,"Charges_pv":\S+,"Feedin_pv":\S+