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),我们将立即处理