對字符串做正則表達式的比較,只比較字符串,不對字符串的值進行比對


   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+

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM