標籤:ase 代碼 exce log and bsp lease soap tle
http://jsonassert.skyscreamer.org/
從這個網站下載jsonassert-1.5.0.jar ,也可以下載到原始碼
JSONObject data = getRESTData("/friends/367.json");String expected = "{friends:[{id:123,name:\"Corby Page\"},{id:456,name:\"Carter Page\"}]}";JSONAssert.assertEquals(expected, data, false);
SoapUI裡面沒有這個jar,把它放在lib目錄下,在SoapUI裡面調用如下:
import org.skyscreamer.jsonassert.*import org.json.JSONObjectdef currentStepIndex = context.currentStepIndexdef previousStepName = testRunner.testCase.getTestStepAt(currentStepIndex-1).namedef prePreStepName = testRunner.testCase.getTestStepAt(currentStepIndex-2).nametry{def expectedJson = new JSONObject(context.expand( ‘${‘+prePreStepName+‘#Response}‘ ))def actualJson = new JSONObject(context.expand( ‘${‘+previousStepName+‘#Response}‘ ))//When strict is set to false (recommended), it forgives reordering data and extending results (as long as all the expected elements are there), making tests less brittle.JSONAssert.assertEquals(expectedJson, actualJson, false)}catch(Exception e){log.info e}
[SoapUI] Compare JSON Response(比較jsonobject)