1、測試代碼
JSONObject jsonObject = new JSONObject(); try { jsonObject.put("amout","100"); } catch (JSONException e) { e.printStackTrace(); } System.out.println( jsonObject.toString()); |
2、異常信息以及原因
java.lang.RuntimeException: Method put in org.json.JSONObject not mocked. |
要在 JUnit 中使用,必須要加上json依賴庫
3、解決方法
下載 json.jar
網址
http://mvnrepository.com
添加依賴
implementation files('libs/json-20200518.jar') |
本文內容不用于商業目的,如涉及知識產權問題,請權利人聯系51Testing小編(021-64471599-8017),我們將立即處理