首页 > 解决方案 > 如何为 Base64.decodeBase64 编写 JUnit 测试

问题描述

下面是我要编写Junit测试用例的方法:

public static byte[] getDecodeBase64(JSONObject object,String key) {
        
  return Base64.decodeBase64(object.getString(key));
}

我写了这个:

@Test
    public void testGetDecodeBase64(){
        
        JSONObject test = new JSONObject();
        test.put("clientId", "test");
        
        String value = "[B@[2807bdeb]";
        
        assertEquals(value, JSONUtil.getDecodeBase64(test, "clientId").toString());
        
    }

但是每次方法返回的值都不一样。

标签: javajunit

解决方案


数组的 toString 方法返回一个表示数组 Id 的字符串。


推荐阅读