MCPcopy Create free account
hub / github.com/ChenSen5/api_autotest / verifyResult

Method verifyResult

src/test/java/test/com/sen/api/TestBase.java:134–156  ·  view source on GitHub ↗
(String sourchData, String verifyStr,
			boolean contains)

Source from the content-addressed store, hash-verified

132 }
133
134 protected void verifyResult(String sourchData, String verifyStr,
135 boolean contains) {
136 if (StringUtil.isEmpty(verifyStr)) {
137 return;
138 }
139 String allVerify = getCommonParam(verifyStr);
140 ReportUtil.log("验证数据:" + allVerify);
141 if (contains) {
142 // 验证结果包含
143 AssertUtil.contains(sourchData, allVerify);
144 } else {
145 // 通过';'分隔,通过jsonPath进行一一校验
146 Pattern pattern = Pattern.compile("([^;]*)=([^;]*)");
147 Matcher m = pattern.matcher(allVerify.trim());
148 while (m.find()) {
149 String actualValue = getBuildValue(sourchData, m.group(1));
150 String exceptValue = getBuildValue(sourchData, m.group(2));
151 ReportUtil.log(String.format("验证转换后的值%s=%s", actualValue,
152 exceptValue));
153 Assert.assertEquals(actualValue, exceptValue, "验证预期结果失败。");
154 }
155 }
156 }
157
158 /**
159 * 获取格式化后的值

Callers 1

apiTestMethod · 0.80

Calls 5

isEmptyMethod · 0.95
getCommonParamMethod · 0.95
logMethod · 0.95
containsMethod · 0.95
getBuildValueMethod · 0.95

Tested by

no test coverage detected