计数项目并在范围报告的test.log中打印

问题描述

我无法在扩展数据报告的test.log()中打印INT类型的变量,我需要此信息。

@Test
    public void CT02_ContandoCategorias() {

        Response response = given().contentType("application/json").get(urlBase);
        test.log(LogStatus.INFO,"Chamando a Api",urlBase);

        List<String> QuantidadeCategorias = response.jsonPath().getList("$");    
    
        test.log(LogStatus.PASS,"Retorno",response.jsonPath().getString("$").length());

    }

我希望您打印报告中的项目数,但您要打印项目的名称

count itens

解决方法

在这种情况下,您可能希望使用不带括号的.length来获取数组中元素的数量,而不是.lenght()来获取String中的字符数量。

请参见https://www.geeksforgeeks.org/length-vs-length-java/